mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Allow parsing a qualified type name containing a reserved word (#18888)
This commit is contained in:
@@ -1217,8 +1217,8 @@ namespace ts {
|
||||
return createIdentifier(isIdentifier(), diagnosticMessage);
|
||||
}
|
||||
|
||||
function parseIdentifierName(): Identifier {
|
||||
return createIdentifier(tokenIsIdentifierOrKeyword(token()));
|
||||
function parseIdentifierName(diagnosticMessage?: DiagnosticMessage): Identifier {
|
||||
return createIdentifier(tokenIsIdentifierOrKeyword(token()), diagnosticMessage);
|
||||
}
|
||||
|
||||
function isLiteralPropertyName(): boolean {
|
||||
@@ -1956,7 +1956,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function parseEntityName(allowReservedWords: boolean, diagnosticMessage?: DiagnosticMessage): EntityName {
|
||||
let entity: EntityName = allowReservedWords ? parseIdentifierName() : parseIdentifier(diagnosticMessage);
|
||||
let entity: EntityName = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
|
||||
let dotPos = scanner.getStartPos();
|
||||
while (parseOptional(SyntaxKind.DotToken)) {
|
||||
if (token() === SyntaxKind.LessThanToken) {
|
||||
@@ -2096,7 +2096,7 @@ namespace ts {
|
||||
|
||||
function parseTypeReference(): TypeReferenceNode {
|
||||
const node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference);
|
||||
node.typeName = parseEntityName(/*allowReservedWords*/ !!(contextFlags & NodeFlags.JSDoc), Diagnostics.Type_expected);
|
||||
node.typeName = parseEntityName(/*allowReservedWords*/ true, Diagnostics.Type_expected);
|
||||
if (!scanner.hasPrecedingLineBreak() && token() === SyntaxKind.LessThanToken) {
|
||||
node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user