fix(48653): throw an error on an invalid optional chain from new expression (#48656)

This commit is contained in:
Oleksandr T authored and GitHub committed 2022-06-02 14:21:36 -07:00
1 parent c6447f9454
commit 2cb8ee27f0
7 files changed
+85

No files matched your search

+4
View File
@@ -651,6 +651,10 @@
"category": "Error",
"code": 1208
},
"Invalid optional chain from new expression. Did you mean to call '{0}()'?": {
"category": "Error",
"code": 1209
},
"Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of '{0}'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode.": {
"category": "Error",
"code": 1210
+3
View File
@@ -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);
}