Skip to content

Commit afe35c8

Browse files
committed
Revert "Support an optional type annotation on export default statement"
This reverts commit a6a8a96.
1 parent 55d6e10 commit afe35c8

16 files changed

Lines changed: 11 additions & 141 deletions

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ module ts {
539539
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
540540
break;
541541
case SyntaxKind.ExportAssignment:
542-
if ((<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
542+
if ((<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
543543
// An export default clause with an identifier exports all meanings of that identifier
544544
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
545545
}

src/compiler/checker.ts

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ module ts {
682682
}
683683

684684
function getTargetOfExportAssignment(node: ExportAssignment): Symbol {
685-
return node.expression && resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
685+
return resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
686686
}
687687

688688
function getTargetOfAliasDeclaration(node: Declaration): Symbol {
@@ -748,7 +748,7 @@ module ts {
748748
if (!links.referenced) {
749749
links.referenced = true;
750750
let node = getDeclarationOfAliasSymbol(symbol);
751-
if (node.kind === SyntaxKind.ExportAssignment && (<ExportAssignment>node).expression) {
751+
if (node.kind === SyntaxKind.ExportAssignment) {
752752
// export default <symbol>
753753
checkExpressionCached((<ExportAssignment>node).expression);
754754
}
@@ -2287,16 +2287,7 @@ module ts {
22872287
}
22882288
// Handle export default expressions
22892289
if (declaration.kind === SyntaxKind.ExportAssignment) {
2290-
var exportAssignment = <ExportAssignment>declaration;
2291-
if (exportAssignment.expression) {
2292-
return links.type = checkExpression(exportAssignment.expression);
2293-
}
2294-
else if (exportAssignment.type) {
2295-
return links.type = getTypeFromTypeNodeOrHeritageClauseElement(exportAssignment.type);
2296-
}
2297-
else {
2298-
return links.type = anyType;
2299-
}
2290+
return links.type = checkExpression((<ExportAssignment>declaration).expression);
23002291
}
23012292
// Handle variable, parameter or property
23022293
links.type = resolvingType;
@@ -10599,21 +10590,12 @@ module ts {
1059910590
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
1060010591
grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
1060110592
}
10602-
if (node.expression) {
10603-
if (node.expression.kind === SyntaxKind.Identifier) {
10604-
markExportAsReferenced(node);
10605-
}
10606-
else {
10607-
checkExpressionCached(node.expression);
10608-
}
10593+
if (node.expression.kind === SyntaxKind.Identifier) {
10594+
markExportAsReferenced(node);
1060910595
}
10610-
if (node.type) {
10611-
checkSourceElement(node.type);
10612-
if (!isInAmbientContext(node)) {
10613-
grammarErrorOnFirstToken(node.type, Diagnostics.A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration);
10614-
}
10596+
else {
10597+
checkExpressionCached(node.expression);
1061510598
}
10616-
1061710599
checkExternalModuleExports(container);
1061810600

1061910601
if (node.isExportEquals && languageVersion >= ScriptTarget.ES6) {

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ module ts {
158158
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." },
159159
Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." },
160160
Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
161-
A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." },
162161
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
163162
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
164163
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },

src/compiler/diagnosticMessages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,6 @@
623623
"category": "Error",
624624
"code": 1200
625625
},
626-
"A type annotation on an export statement is only allowed in an ambient external module declaration.": {
627-
"category": "Error",
628-
"code": 1201
629-
},
630626
"Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": {
631627
"category": "Error",
632628
"code": 1202

src/compiler/parser.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ module ts {
299299
case SyntaxKind.ExportAssignment:
300300
return visitNodes(cbNodes, node.decorators) ||
301301
visitNodes(cbNodes, node.modifiers) ||
302-
visitNode(cbNode, (<ExportAssignment>node).expression) ||
303-
visitNode(cbNode, (<ExportAssignment>node).type);
302+
visitNode(cbNode, (<ExportAssignment>node).expression);
304303
case SyntaxKind.TemplateExpression:
305304
return visitNode(cbNode, (<TemplateExpression>node).head) || visitNodes(cbNodes, (<TemplateExpression>node).templateSpans);
306305
case SyntaxKind.TemplateSpan:
@@ -5123,17 +5122,11 @@ module ts {
51235122
setModifiers(node, modifiers);
51245123
if (parseOptional(SyntaxKind.EqualsToken)) {
51255124
node.isExportEquals = true;
5126-
node.expression = parseAssignmentExpressionOrHigher();
51275125
}
51285126
else {
51295127
parseExpected(SyntaxKind.DefaultKeyword);
5130-
if (parseOptional(SyntaxKind.ColonToken)) {
5131-
node.type = parseType();
5132-
}
5133-
else {
5134-
node.expression = parseAssignmentExpressionOrHigher();
5135-
}
51365128
}
5129+
node.expression = parseAssignmentExpressionOrHigher();
51375130
parseSemicolon();
51385131
return finishNode(node);
51395132
}

src/compiler/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,8 +975,7 @@ module ts {
975975

976976
export interface ExportAssignment extends Declaration, ModuleElement {
977977
isExportEquals?: boolean;
978-
expression?: Expression;
979-
type?: TypeNode;
978+
expression: Expression;
980979
}
981980

982981
export interface FileReference extends TextRange {

src/services/breakpoints.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,6 @@ module ts.BreakpointResolver {
173173
return textSpan(node, (<ThrowStatement>node).expression);
174174

175175
case SyntaxKind.ExportAssignment:
176-
if (!(<ExportAssignment>node).expression) {
177-
return undefined;
178-
}
179-
180176
// span on export = id
181177
return textSpan(node, (<ExportAssignment>node).expression);
182178

tests/baselines/reference/exportDefaultTypeAnnoation.errors.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/baselines/reference/exportDefaultTypeAnnoation.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/baselines/reference/exportDefaultTypeAnnoation2.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)