Add es6 module kind, stop using script version to infer it

This commit is contained in:
Wesley Wigham
2015-09-15 15:36:37 -07:00
parent bccd1762f2
commit 48ba708e5e
50 changed files with 814 additions and 342 deletions

View File

@@ -343,6 +343,10 @@ namespace ts {
let classifiableNames: Map<string>;
let skipDefaultLib = options.noLib;
if (options.target >= ScriptTarget.ES6 && !options.module) { // Preserve old ES6 module behavior
options.module = ModuleKind.ES6;
}
let start = new Date().getTime();
@@ -1022,9 +1026,9 @@ namespace ts {
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided));
}
// Cannot specify module gen target when in es6 or above
if (options.module && languageVersion >= ScriptTarget.ES6) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_commonjs_amd_system_or_umd_when_targeting_ES6_or_higher));
// Cannot specify module gen target of es6 when below es6
if (options.module === ModuleKind.ES6 && languageVersion < ScriptTarget.ES6) {
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es6_when_targeting_ES5_or_lower));
}
// there has to be common source directory if user specified --outdir || --sourceRoot