Skip to content

Commit d85581b

Browse files
committed
Do not create Name of the importSpecifier if it isnt identifier, to avoid creating missing symbols
Missing symbols are defined when the declaration doesnt have name, so if we created node for missing identifier it would end up binding symbol with name (Missing)
1 parent c521fe4 commit d85581b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/compiler/parser.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4656,21 +4656,27 @@ module ts {
46564656
// ImportSpecifier:
46574657
// ImportedBinding
46584658
// IdentifierName as ImportedBinding
4659-
var isfirstIdentifierNameNotAnIdentifier = isKeyword(token) && !isIdentifier();
4659+
var isFirstIdentifierNameNotAnIdentifier = isKeyword(token) && !isIdentifier();
46604660
var start = scanner.getTokenPos();
46614661
var identifierName = parseIdentifierName();
46624662
if (token === SyntaxKind.AsKeyword) {
46634663
node.propertyName = identifierName;
46644664
parseExpected(SyntaxKind.AsKeyword);
4665-
node.name = parseIdentifier();
4665+
if (isIdentifier()) {
4666+
node.name = parseIdentifierName();
4667+
}
4668+
else {
4669+
parseErrorAtCurrentToken(Diagnostics.Identifier_expected);
4670+
}
46664671
}
46674672
else {
46684673
node.name = identifierName;
4669-
if (isfirstIdentifierNameNotAnIdentifier) {
4674+
if (isFirstIdentifierNameNotAnIdentifier) {
46704675
// Report error identifier expected
46714676
parseErrorAtPosition(start, identifierName.end - start, Diagnostics.Identifier_expected);
46724677
}
46734678
}
4679+
46744680
return finishNode(node);
46754681
}
46764682

0 commit comments

Comments
 (0)