diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 6bbf1eae04c..55258162d23 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1789,4 +1789,4 @@ namespace Harness { } if (Error) (Error).stackTraceLimit = 1; -} \ No newline at end of file +} diff --git a/src/services/services.ts b/src/services/services.ts index 50070d8fa73..cdf31ea3197 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1951,17 +1951,11 @@ namespace ts { let commandLineOptionsStringToEnum: CommandLineOptionOfCustomType[]; - /** - * Convert an option's string name of enum-value in compiler-options, "options", into its corresponding enum value if possible. - * This is necessary because JS users may pass in string values for enum compiler options (e.g. ModuleKind). - * - * @param options a compiler-options used in transpilation which can contain string value to specify instead of enum values - * @param diagnostics a list of Diagnostic which occur during conversion (e.g invalid option's value) - */ - function ConvertStringForEnumNameInCompilerOptionsToEnumValue(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions { + /** JS users may pass in string values for enum compiler options (such as ModuleKind), so convert. */ + function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || filter(optionDeclarations, o => - typeof o.type === "object" && !forEachValue(> o.type, v => typeof v !== "number")); + typeof o.type === "object" && !forEachValue(> o.type, v => typeof v !== "number")); options = clone(options); @@ -1999,7 +1993,7 @@ namespace ts { export function transpileModule(input: string, transpileOptions: TranspileOptions): TranspileOutput { const diagnostics: Diagnostic[] = []; - const options: CompilerOptions = transpileOptions.compilerOptions ? ConvertStringForEnumNameInCompilerOptionsToEnumValue(transpileOptions.compilerOptions, diagnostics) : getDefaultCompilerOptions(); + const options: CompilerOptions = transpileOptions.compilerOptions ? fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics) : getDefaultCompilerOptions(); options.isolatedModules = true; diff --git a/tests/baselines/reference/disallowAsyncModifierInES5.js b/tests/baselines/reference/disallowAsyncModifierInES5.js index e0997f13110..b26ce1084ee 100644 --- a/tests/baselines/reference/disallowAsyncModifierInES5.js +++ b/tests/baselines/reference/disallowAsyncModifierInES5.js @@ -1,7 +1,7 @@ //// [disallowAsyncModifierInES5.ts] - -async function foo() { return 42; } // ERROR: Async functions are only available in ES6+ -let bar = async function () { return 42; } // OK, but should be an error + +async function foo() { return 42; } // ERROR: Async functions are only available in ES6+ +let bar = async function () { return 42; } // OK, but should be an error let baz = async () => 42; // OK, but should be an error //// [disallowAsyncModifierInES5.js] @@ -20,4 +20,4 @@ function foo() { var bar = function () { return __awaiter(this, void 0, void 0, function* () { return 42; }); }; // OK, but should be an error -var baz = function () { return __awaiter(_this, void 0, void 0, function* () { return 42; }); }; // OK, but should be an error +var baz = function () { return __awaiter(_this, void 0, void 0, function* () { return 42; }); }; // OK, but should be an error \ No newline at end of file