Enhancement new expression with type arguments without parenthesized argument list error message (#37576)

* Enhancement new expression with type arguments without parenthesized argument list error message

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>

* add baselines

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>

* use parseErrorAt

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>

* refine code

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>

* Space before paren

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
Rustin
2020-03-26 03:37:46 +08:00
committed by GitHub
parent b7b2c333a9
commit 8615eecfc1
12 changed files with 30 additions and 23 deletions

View File

@@ -1147,6 +1147,10 @@
"category": "Error",
"code": 1383
},
"A 'new' expression with type arguments must always be followed by a parenthesized argument list.": {
"category": "Error",
"code": 1384
},
"The types of '{0}' are incompatible between these types.": {
"category": "Error",

View File

@@ -5199,9 +5199,12 @@ namespace ts {
const node = <NewExpression>createNode(SyntaxKind.NewExpression, fullStart);
node.expression = expression;
node.typeArguments = typeArguments;
if (node.typeArguments || token() === SyntaxKind.OpenParenToken) {
if (token() === SyntaxKind.OpenParenToken) {
node.arguments = parseArgumentList();
}
else if (node.typeArguments) {
parseErrorAt(fullStart, scanner.getStartPos(), Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
}
return finishNode(node);
}