mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-22 16:52:14 -06:00
Disallow modifiers on export assignments (fix #164)
This commit is contained in:
parent
c1be793a04
commit
478fadfe3d
@ -104,6 +104,7 @@ module ts {
|
||||
An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple properties with the same name in strict mode." },
|
||||
An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: { code: 1118, category: DiagnosticCategory.Error, key: "An object literal cannot have multiple get/set accessors with the same name." },
|
||||
An_object_literal_cannot_have_property_and_accessor_with_the_same_name: { code: 1119, category: DiagnosticCategory.Error, key: "An object literal cannot have property and accessor with the same name." },
|
||||
An_export_assignment_cannot_have_modifiers: { code: 1120, category: DiagnosticCategory.Error, key: "An export assignment cannot have modifiers." },
|
||||
Duplicate_identifier_0: { code: 2000, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 2068, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
|
||||
Multiple_constructor_implementations_are_not_allowed: { code: 2070, category: DiagnosticCategory.Error, key: "Multiple constructor implementations are not allowed." },
|
||||
|
||||
@ -408,6 +408,10 @@
|
||||
"category": "Error",
|
||||
"code": 1119
|
||||
},
|
||||
"An export assignment cannot have modifiers.": {
|
||||
"category": "Error",
|
||||
"code": 1120
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2000
|
||||
|
||||
@ -3348,9 +3348,15 @@ module ts {
|
||||
var flags = parseAndCheckModifiers(modifierContext);
|
||||
|
||||
if (token === SyntaxKind.ExportKeyword) {
|
||||
var modifiersEnd = scanner.getStartPos();
|
||||
nextToken();
|
||||
if (parseOptional(SyntaxKind.EqualsToken)) {
|
||||
return parseExportAssignmentTail(pos);
|
||||
var exportAssignmentTail = parseExportAssignmentTail(pos);
|
||||
if (flags !== 0 && errorCountBeforeModifiers === file.syntacticErrors.length) {
|
||||
var modifiersStart = skipTrivia(sourceText, pos);
|
||||
grammarErrorAtPos(modifiersStart, modifiersEnd - modifiersStart, Diagnostics.An_export_assignment_cannot_have_modifiers);
|
||||
}
|
||||
return exportAssignmentTail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
==== tests/cases/compiler/exportAssignmentWithDeclareAndExportModifiers.ts (2 errors) ====
|
||||
var x;
|
||||
export declare export = x;
|
||||
~~~~~~~~~~~~~~
|
||||
!!! An export assignment cannot have modifiers.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! Cannot compile external modules unless the '--module' flag is provided.
|
||||
@ -0,0 +1,7 @@
|
||||
==== tests/cases/compiler/exportAssignmentWithDeclareModifier.ts (2 errors) ====
|
||||
var x;
|
||||
declare export = x;
|
||||
~~~~~~~
|
||||
!!! An export assignment cannot have modifiers.
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! Cannot compile external modules unless the '--module' flag is provided.
|
||||
@ -0,0 +1,7 @@
|
||||
==== tests/cases/compiler/exportAssignmentWithExportModifier.ts (2 errors) ====
|
||||
var x;
|
||||
export export = x;
|
||||
~~~~~~
|
||||
!!! An export assignment cannot have modifiers.
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! Cannot compile external modules unless the '--module' flag is provided.
|
||||
@ -0,0 +1,2 @@
|
||||
var x;
|
||||
export declare export = x;
|
||||
@ -0,0 +1,2 @@
|
||||
var x;
|
||||
declare export = x;
|
||||
@ -0,0 +1,2 @@
|
||||
var x;
|
||||
export export = x;
|
||||
Loading…
x
Reference in New Issue
Block a user