Skip to content

Commit 6fc5523

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into typeParameterFixing
2 parents 28c4b02 + c4cb3e3 commit 6fc5523

File tree

227 files changed

+2793
-2103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+2793
-2103
lines changed

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ module ts {
505505
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
506506
break;
507507
case SyntaxKind.ExportAssignment:
508-
if ((<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
508+
if ((<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
509509
// An export default clause with an identifier exports all meanings of that identifier
510510
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
511511
}

src/compiler/checker.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ module ts {
566566
}
567567

568568
function getTargetOfExportAssignment(node: ExportAssignment): Symbol {
569-
return resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
569+
return node.expression && resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
570570
}
571571

572572
function getTargetOfImportDeclaration(node: Declaration): Symbol {
@@ -622,7 +622,7 @@ module ts {
622622
if (!links.referenced) {
623623
links.referenced = true;
624624
let node = getDeclarationOfAliasSymbol(symbol);
625-
if (node.kind === SyntaxKind.ExportAssignment) {
625+
if (node.kind === SyntaxKind.ExportAssignment && (<ExportAssignment>node).expression) {
626626
// export default <symbol>
627627
checkExpressionCached((<ExportAssignment>node).expression);
628628
}
@@ -2072,7 +2072,16 @@ module ts {
20722072
}
20732073
// Handle export default expressions
20742074
if (declaration.kind === SyntaxKind.ExportAssignment) {
2075-
return links.type = checkExpression((<ExportAssignment>declaration).expression);
2075+
var exportAssignment = <ExportAssignment>declaration;
2076+
if (exportAssignment.expression) {
2077+
return links.type = checkExpression(exportAssignment.expression);
2078+
}
2079+
else if (exportAssignment.type) {
2080+
return links.type = getTypeFromTypeNode(exportAssignment.type);
2081+
}
2082+
else {
2083+
return links.type = anyType;
2084+
}
20762085
}
20772086
// Handle variable, parameter or property
20782087
links.type = resolvingType;
@@ -10112,12 +10121,21 @@ module ts {
1011210121
if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
1011310122
grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
1011410123
}
10115-
if (node.expression.kind === SyntaxKind.Identifier) {
10116-
markExportAsReferenced(node);
10124+
if (node.expression) {
10125+
if (node.expression.kind === SyntaxKind.Identifier) {
10126+
markExportAsReferenced(node);
10127+
}
10128+
else {
10129+
checkExpressionCached(node.expression);
10130+
}
1011710131
}
10118-
else {
10119-
checkExpressionCached(node.expression);
10132+
if (node.type) {
10133+
checkSourceElement(node.type);
10134+
if (!isInAmbientContext(node)) {
10135+
grammarErrorOnFirstToken(node.type, Diagnostics.A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration);
10136+
}
1012010137
}
10138+
1012110139
checkExternalModuleExports(container);
1012210140
}
1012310141

@@ -10951,7 +10969,7 @@ module ts {
1095110969
}
1095210970

1095310971
function generateNameForExportAssignment(node: ExportAssignment) {
10954-
if (node.expression.kind !== SyntaxKind.Identifier) {
10972+
if (node.expression && node.expression.kind !== SyntaxKind.Identifier) {
1095510973
assignGeneratedName(node, makeUniqueName("default"));
1095610974
}
1095710975
}

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ 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." },
161162
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
162163
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." },
163164
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },

src/compiler/diagnosticMessages.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,17 @@
617617
},
618618
"Unterminated Unicode escape sequence.": {
619619
"category": "Error",
620-
"code": 1199
620+
"code": 1199
621621
},
622622
"Line terminator not permitted before arrow.": {
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+
},
630+
626631
"Duplicate identifier '{0}'.": {
627632
"category": "Error",
628633
"code": 2300

0 commit comments

Comments
 (0)