mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Dont default to CommonJS modules for ES6 target
This commit is contained in:
parent
73fa45bd2e
commit
4a67dc5e08
@ -49,7 +49,7 @@ namespace ts {
|
||||
|
||||
const compilerOptions = host.getCompilerOptions();
|
||||
const languageVersion = compilerOptions.target || ScriptTarget.ES3;
|
||||
const modulekind = typeof compilerOptions.module === "number" ? compilerOptions.module : languageVersion === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS;
|
||||
const modulekind = getEmitModuleKind(compilerOptions);
|
||||
const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System;
|
||||
|
||||
const emitResolver = createResolver();
|
||||
|
||||
@ -580,7 +580,6 @@ namespace ts {
|
||||
const options: CompilerOptions = {};
|
||||
const errors: Diagnostic[] = [];
|
||||
|
||||
options.module = ModuleKind.CommonJS;
|
||||
if (configFileName && getBaseFileName(configFileName) === "jsconfig.json") {
|
||||
options.allowJs = true;
|
||||
}
|
||||
|
||||
@ -1290,7 +1290,7 @@ namespace ts {
|
||||
|
||||
const firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
|
||||
if (options.isolatedModules) {
|
||||
if (!options.module && languageVersion < ScriptTarget.ES6) {
|
||||
if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES6) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher));
|
||||
}
|
||||
|
||||
@ -1300,7 +1300,7 @@ namespace ts {
|
||||
programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided));
|
||||
}
|
||||
}
|
||||
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && !options.module) {
|
||||
else if (firstExternalModuleSourceFile && languageVersion < ScriptTarget.ES6 && options.module === ModuleKind.None) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
const span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file));
|
||||
|
||||
@ -974,7 +974,6 @@ namespace Harness {
|
||||
|
||||
const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? ts.clone(compilerOptions) : { noResolve: false };
|
||||
options.target = options.target || ts.ScriptTarget.ES3;
|
||||
options.module = options.module || ts.ModuleKind.None;
|
||||
options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed;
|
||||
options.noErrorTruncation = true;
|
||||
options.skipDefaultLibCheck = true;
|
||||
|
||||
@ -1712,7 +1712,6 @@ namespace ts {
|
||||
// Always default to "ScriptTarget.ES5" for the language service
|
||||
return {
|
||||
target: ScriptTarget.ES5,
|
||||
module: ModuleKind.CommonJS,
|
||||
jsx: JsxEmit.Preserve
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user