Report error on export assignment with es6 and above target
Conflicts: src/compiler/checker.ts tests/baselines/reference/es6ImportDefaultBinding.errors.txt tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts
This commit is contained in:
parent
e902d8462e
commit
61a5bfb09d
7 changed files with 38 additions and 1 deletions
|
@ -9940,6 +9940,11 @@ module ts {
|
|||
checkExpressionCached(node.expression);
|
||||
}
|
||||
checkExternalModuleExports(container);
|
||||
|
||||
if (compilerOptions.target >= 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);
|
||||
}
|
||||
}
|
||||
|
||||
function getModuleStatements(node: Declaration): ModuleElement[] {
|
||||
|
|
|
@ -158,6 +158,7 @@ module ts {
|
|||
An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." },
|
||||
Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." },
|
||||
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: { code: 1200, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
|
||||
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1201, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
|
||||
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
|
||||
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
|
||||
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
|
||||
|
|
|
@ -623,6 +623,10 @@
|
|||
"category": "Error",
|
||||
"code": 1200
|
||||
},
|
||||
"Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": {
|
||||
"category": "Error",
|
||||
"code": 1201
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
|
|
12
tests/baselines/reference/es6ExportAssignment.errors.txt
Normal file
12
tests/baselines/reference/es6ExportAssignment.errors.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||
tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1201: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
|
||||
|
||||
==== tests/cases/compiler/es6ExportAssignment.ts (2 errors) ====
|
||||
|
||||
var a = 10;
|
||||
export = a;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1201: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
8
tests/baselines/reference/es6ExportAssignment.js
Normal file
8
tests/baselines/reference/es6ExportAssignment.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [es6ExportAssignment.ts]
|
||||
|
||||
var a = 10;
|
||||
export = a;
|
||||
|
||||
//// [es6ExportAssignment.js]
|
||||
var a = 10;
|
||||
module.exports = a;
|
|
@ -1,15 +1,18 @@
|
|||
tests/cases/compiler/client.ts(1,1): error TS1200: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
|
||||
tests/cases/compiler/server.ts(3,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||
tests/cases/compiler/server.ts(3,1): error TS1201: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
|
||||
|
||||
==== tests/cases/compiler/client.ts (1 errors) ====
|
||||
import a = require("server");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1200: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
|
||||
==== tests/cases/compiler/server.ts (1 errors) ====
|
||||
==== tests/cases/compiler/server.ts (2 errors) ====
|
||||
|
||||
var a = 10;
|
||||
export = a;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1201: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
|
4
tests/cases/compiler/es6ExportAssignment.ts
Normal file
4
tests/cases/compiler/es6ExportAssignment.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
// @target: es6
|
||||
|
||||
var a = 10;
|
||||
export = a;
|
Loading…
Reference in a new issue