Skip to content

Commit 4b75484

Browse files
sheetalkamatmhegazy
authored andcommitted
Fix the checks with language version to use default es3
1 parent 3ed8bcc commit 4b75484

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

‎src/compiler/checker.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ module ts {
724724
}
725725

726726
function getExportsForModule(moduleSymbol: Symbol): SymbolTable {
727-
if (compilerOptions.target < ScriptTarget.ES6) {
727+
if (languageVersion < ScriptTarget.ES6) {
728728
// A default export hides all other exports in CommonJS and AMD modules
729729
var defaultSymbol = getExportAssignmentSymbol(moduleSymbol);
730730
if (defaultSymbol) {
@@ -9902,7 +9902,7 @@ module ts {
99029902
}
99039903
}
99049904
else {
9905-
if (compilerOptions.target >= ScriptTarget.ES6) {
9905+
if (languageVersion >= ScriptTarget.ES6) {
99069906
// Import equals declaration is deprecated in es6 or above
99079907
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_from_mod_import_a_from_mod_or_import_d_from_mod_instead);
99089908
}
@@ -9946,7 +9946,7 @@ module ts {
99469946
}
99479947
checkExternalModuleExports(container);
99489948

9949-
if (compilerOptions.target >= ScriptTarget.ES6) {
9949+
if (languageVersion >= ScriptTarget.ES6) {
99509950
// export assignment is deprecated in es6 or above
99519951
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead);
99529952
}

‎src/compiler/emitter.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3228,7 +3228,7 @@ module ts {
32283228
}
32293229

32303230
function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void {
3231-
if (compilerOptions.target >= ScriptTarget.ES6) {
3231+
if (languageVersion >= ScriptTarget.ES6) {
32323232
emit(node.tag);
32333233
write(" ");
32343234
emit(node.template);
@@ -4997,7 +4997,7 @@ module ts {
49974997
}
49984998

49994999
function emitImportDeclaration(node: ImportDeclaration) {
5000-
if (compilerOptions.target < ScriptTarget.ES6) {
5000+
if (languageVersion < ScriptTarget.ES6) {
50015001
return emitExternalImportDeclaration(node);
50025002
}
50035003

@@ -5067,7 +5067,7 @@ module ts {
50675067
}
50685068

50695069
function emitImportSpecifier(node: ImportSpecifier) {
5070-
Debug.assert(compilerOptions.target >= ScriptTarget.ES6);
5070+
Debug.assert(languageVersion >= ScriptTarget.ES6);
50715071
if (node.propertyName) {
50725072
emit(node.propertyName);
50735073
write(" as ");
@@ -5413,7 +5413,7 @@ module ts {
54135413
extendsEmitted = true;
54145414
}
54155415
if (isExternalModule(node)) {
5416-
if (compilerOptions.target >= ScriptTarget.ES6) {
5416+
if (languageVersion >= ScriptTarget.ES6) {
54175417
emitES6Module(node, startIndex);
54185418
}
54195419
else if (compilerOptions.module === ModuleKind.AMD) {

‎src/compiler/program.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,17 +426,19 @@ module ts {
426426
return;
427427
}
428428

429+
var languageVersion = options.target || ScriptTarget.ES3;
430+
429431
var firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
430432
if (firstExternalModuleSourceFile && !options.module) {
431-
if (!options.module && options.target < ScriptTarget.ES6) {
433+
if (!options.module && languageVersion < ScriptTarget.ES6) {
432434
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
433435
var span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
434436
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided));
435437
}
436438
}
437439

438440
// Cannot specify module gen target when in es6 or above
439-
if (options.module && options.target >= ScriptTarget.ES6) {
441+
if (options.module && languageVersion >= ScriptTarget.ES6) {
440442
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher));
441443
}
442444

0 commit comments

Comments
 (0)