mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix(48653): throw an error on an invalid optional chain from new expression (#48656)
This commit is contained in:
@@ -5942,6 +5942,9 @@ namespace ts {
|
||||
typeArguments = (expression as ExpressionWithTypeArguments).typeArguments;
|
||||
expression = (expression as ExpressionWithTypeArguments).expression;
|
||||
}
|
||||
if (token() === SyntaxKind.QuestionDotToken) {
|
||||
parseErrorAtCurrentToken(Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, getTextOfNodeFromSourceText(sourceText, expression));
|
||||
}
|
||||
const argumentList = token() === SyntaxKind.OpenParenToken ? parseArgumentList() : undefined;
|
||||
return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user