mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-12 01:29:50 -05:00
Allow '!' only on variable declarations within variable statements
This commit is contained in:
@@ -5252,10 +5252,15 @@ namespace ts {
|
||||
return parseIdentifier();
|
||||
}
|
||||
|
||||
function parseVariableDeclaration(): VariableDeclaration {
|
||||
function parseVariableDeclarationAllowExclamation() {
|
||||
return parseVariableDeclaration(/*allowExclamation*/ true);
|
||||
}
|
||||
|
||||
function parseVariableDeclaration(allowExclamation?: boolean): VariableDeclaration {
|
||||
const node = <VariableDeclaration>createNode(SyntaxKind.VariableDeclaration);
|
||||
node.name = parseIdentifierOrPattern();
|
||||
if (node.name.kind === SyntaxKind.Identifier && token() === SyntaxKind.ExclamationToken && !scanner.hasPrecedingLineBreak()) {
|
||||
if (allowExclamation && node.name.kind === SyntaxKind.Identifier &&
|
||||
token() === SyntaxKind.ExclamationToken && !scanner.hasPrecedingLineBreak()) {
|
||||
node.exclamationToken = parseTokenNode();
|
||||
}
|
||||
node.type = parseTypeAnnotation();
|
||||
@@ -5299,7 +5304,8 @@ namespace ts {
|
||||
const savedDisallowIn = inDisallowInContext();
|
||||
setDisallowInContext(inForStatementInitializer);
|
||||
|
||||
node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration);
|
||||
node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations,
|
||||
inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation);
|
||||
|
||||
setDisallowInContext(savedDisallowIn);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user