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 {
if (compilerOptions.target < ScriptTarget.ES6) {
if (languageVersion < ScriptTarget.ES6) {
// A default export hides all other exports in CommonJS and AMD modules
var defaultSymbol = getExportAssignmentSymbol(moduleSymbol);
if (defaultSymbol) {
@ -9902,7 +9902,7 @@ module ts {
}
}
else {
if (compilerOptions.target >= ScriptTarget.ES6) {
if (languageVersion >= ScriptTarget.ES6) {
// 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);
}
@ -9946,7 +9946,7 @@ module ts {
}
checkExternalModuleExports(container);
if (compilerOptions.target >= ScriptTarget.ES6) {
if (languageVersion >= ScriptTarget.ES6) {
// 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);
}

View file

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

View file

@ -426,9 +426,11 @@ module ts {
return;
}
var languageVersion = options.target || ScriptTarget.ES3;
var firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
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
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));
@ -436,7 +438,7 @@ module ts {
}
// 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));
}