Fix the checks with language version to use default es3

This commit is contained in:
Sheetal Nandi 2015-02-12 17:54:30 -08:00 committed by Mohamed Hegazy
parent 3ed8bcc179
commit 4b7548487c
3 changed files with 11 additions and 9 deletions

View file

@ -724,7 +724,7 @@ module ts {
} }
function getExportsForModule(moduleSymbol: Symbol): SymbolTable { function getExportsForModule(moduleSymbol: Symbol): SymbolTable {
if (compilerOptions.target < ScriptTarget.ES6) { if (languageVersion < ScriptTarget.ES6) {
// A default export hides all other exports in CommonJS and AMD modules // A default export hides all other exports in CommonJS and AMD modules
var defaultSymbol = getExportAssignmentSymbol(moduleSymbol); var defaultSymbol = getExportAssignmentSymbol(moduleSymbol);
if (defaultSymbol) { if (defaultSymbol) {
@ -9902,7 +9902,7 @@ module ts {
} }
} }
else { else {
if (compilerOptions.target >= ScriptTarget.ES6) { if (languageVersion >= ScriptTarget.ES6) {
// Import equals declaration is deprecated in es6 or above // Import equals declaration is deprecated in es6 or above
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); 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);
} }
@ -9946,7 +9946,7 @@ module ts {
} }
checkExternalModuleExports(container); checkExternalModuleExports(container);
if (compilerOptions.target >= ScriptTarget.ES6) { if (languageVersion >= ScriptTarget.ES6) {
// export assignment is deprecated in es6 or above // export assignment is deprecated in es6 or above
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead); grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead);
} }

View file

@ -3228,7 +3228,7 @@ module ts {
} }
function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void { function emitTaggedTemplateExpression(node: TaggedTemplateExpression): void {
if (compilerOptions.target >= ScriptTarget.ES6) { if (languageVersion >= ScriptTarget.ES6) {
emit(node.tag); emit(node.tag);
write(" "); write(" ");
emit(node.template); emit(node.template);
@ -4997,7 +4997,7 @@ module ts {
} }
function emitImportDeclaration(node: ImportDeclaration) { function emitImportDeclaration(node: ImportDeclaration) {
if (compilerOptions.target < ScriptTarget.ES6) { if (languageVersion < ScriptTarget.ES6) {
return emitExternalImportDeclaration(node); return emitExternalImportDeclaration(node);
} }
@ -5067,7 +5067,7 @@ module ts {
} }
function emitImportSpecifier(node: ImportSpecifier) { function emitImportSpecifier(node: ImportSpecifier) {
Debug.assert(compilerOptions.target >= ScriptTarget.ES6); Debug.assert(languageVersion >= ScriptTarget.ES6);
if (node.propertyName) { if (node.propertyName) {
emit(node.propertyName); emit(node.propertyName);
write(" as "); write(" as ");
@ -5413,7 +5413,7 @@ module ts {
extendsEmitted = true; extendsEmitted = true;
} }
if (isExternalModule(node)) { if (isExternalModule(node)) {
if (compilerOptions.target >= ScriptTarget.ES6) { if (languageVersion >= ScriptTarget.ES6) {
emitES6Module(node, startIndex); emitES6Module(node, startIndex);
} }
else if (compilerOptions.module === ModuleKind.AMD) { else if (compilerOptions.module === ModuleKind.AMD) {

View file

@ -426,9 +426,11 @@ module ts {
return; return;
} }
var languageVersion = options.target || ScriptTarget.ES3;
var firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined); var firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
if (firstExternalModuleSourceFile && !options.module) { if (firstExternalModuleSourceFile && !options.module) {
if (!options.module && options.target < ScriptTarget.ES6) { if (!options.module && languageVersion < ScriptTarget.ES6) {
// We cannot use createDiagnosticFromNode because nodes do not have parents yet // We cannot use createDiagnosticFromNode because nodes do not have parents yet
var span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); var span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided)); diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided));
@ -436,7 +438,7 @@ module ts {
} }
// Cannot specify module gen target when in es6 or above // Cannot specify module gen target when in es6 or above
if (options.module && options.target >= ScriptTarget.ES6) { if (options.module && languageVersion >= ScriptTarget.ES6) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher)); diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher));
} }