mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 11:24:49 -05:00
Merge branch 'master' into transforms
# Conflicts: # Jakefile.js # src/compiler/emitter.ts # src/compiler/program.ts # src/compiler/types.ts # src/harness/harness.ts # src/services/services.ts # tests/baselines/reference/disallowAsyncModifierInES5.js # tests/baselines/reference/es5andes6module.js # tests/baselines/reference/es6ExportClauseWithAssignmentInEs5.js # tests/baselines/reference/es6modulekindWithES5Target.js # tests/baselines/reference/es6modulekindWithES5Target11.js # tests/baselines/reference/es6modulekindWithES5Target2.js # tests/baselines/reference/es6modulekindWithES5Target3.js # tests/baselines/reference/es6modulekindWithES5Target6.js # tests/cases/unittests/transpile.ts # tests/cases/unittests/tsserverProjectSystem.ts
This commit is contained in:
@@ -1789,4 +1789,4 @@ namespace Harness {
|
||||
}
|
||||
|
||||
if (Error) (<any>Error).stackTraceLimit = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 || <CommandLineOptionOfCustomType[]>filter(optionDeclarations, o =>
|
||||
typeof o.type === "object" && !forEachValue(<Map<number | string>> o.type, v => typeof v !== "number"));
|
||||
typeof o.type === "object" && !forEachValue(<Map<any>> 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;
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user