@@ -16363,7 +16363,7 @@ namespace ts {
16363
16363
*/
16364
16364
function checkCallExpression(node: CallExpression | NewExpression): Type {
16365
16365
// Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true
16366
- checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node .arguments);
16366
+ checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node.arguments);
16367
16367
16368
16368
const signature = getResolvedSignature(node);
16369
16369
@@ -16411,7 +16411,7 @@ namespace ts {
16411
16411
16412
16412
function checkImportCallExpression(node: ImportCall): Type {
16413
16413
// Check grammar of dynamic import
16414
- checkGrammarArguments(node, node .arguments) || checkGrammarImportCallExpression(node);
16414
+ checkGrammarArguments(node.arguments) || checkGrammarImportCallExpression(node);
16415
16415
16416
16416
if (node.arguments.length === 0) {
16417
16417
return createPromiseReturnType(node, anyType);
@@ -18700,7 +18700,7 @@ namespace ts {
18700
18700
function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) {
18701
18701
checkGrammarTypeArguments(node, node.typeArguments);
18702
18702
if (node.kind === SyntaxKind.TypeReference && node.typeName.jsdocDotPos !== undefined && !isInJavaScriptFile(node) && !isInJSDoc(node)) {
18703
- grammarErrorAtPos(getSourceFileOfNode( node) , node.typeName.jsdocDotPos, 1, Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
18703
+ grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
18704
18704
18705
18705
}
18706
18706
const type = getTypeFromTypeReference(node);
@@ -24136,8 +24136,7 @@ namespace ts {
24136
24136
if (list && list.hasTrailingComma) {
24137
24137
const start = list.end - ",".length;
24138
24138
const end = list.end;
24139
- const sourceFile = getSourceFileOfNode(list[0]);
24140
- return grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Trailing_comma_not_allowed);
24139
+ return grammarErrorAtPos(list[0], start, end - start, Diagnostics.Trailing_comma_not_allowed);
24141
24140
}
24142
24141
}
24143
24142
@@ -24265,19 +24264,18 @@ namespace ts {
24265
24264
checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
24266
24265
}
24267
24266
24268
- function checkGrammarForOmittedArgument(node: CallExpression | NewExpression, args: NodeArray<Expression>): boolean {
24267
+ function checkGrammarForOmittedArgument(args: NodeArray<Expression>): boolean {
24269
24268
if (args) {
24270
- const sourceFile = getSourceFileOfNode(node);
24271
24269
for (const arg of args) {
24272
24270
if (arg.kind === SyntaxKind.OmittedExpression) {
24273
- return grammarErrorAtPos(sourceFile , arg.pos, 0, Diagnostics.Argument_expression_expected);
24271
+ return grammarErrorAtPos(arg , arg.pos, 0, Diagnostics.Argument_expression_expected);
24274
24272
}
24275
24273
}
24276
24274
}
24277
24275
}
24278
24276
24279
- function checkGrammarArguments(node: CallExpression | NewExpression, args: NodeArray<Expression>): boolean {
24280
- return checkGrammarForOmittedArgument(node, args);
24277
+ function checkGrammarArguments(args: NodeArray<Expression>): boolean {
24278
+ return checkGrammarForOmittedArgument(args);
24281
24279
}
24282
24280
24283
24281
function checkGrammarHeritageClause(node: HeritageClause): boolean {
@@ -24287,8 +24285,7 @@ namespace ts {
24287
24285
}
24288
24286
if (types && types.length === 0) {
24289
24287
const listType = tokenToString(node.token);
24290
- const sourceFile = getSourceFileOfNode(node);
24291
- return grammarErrorAtPos(sourceFile, types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType);
24288
+ return grammarErrorAtPos(node, types.pos, 0, Diagnostics._0_list_cannot_be_empty, listType);
24292
24289
}
24293
24290
return forEach(types, checkGrammarExpressionWithTypeArguments);
24294
24291
}
@@ -24566,7 +24563,7 @@ namespace ts {
24566
24563
return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_be_declared_in_an_ambient_context);
24567
24564
}
24568
24565
else if (accessor.body === undefined && !hasModifier(accessor, ModifierFlags.Abstract)) {
24569
- return grammarErrorAtPos(getSourceFileOfNode( accessor) , accessor.end - 1, ";".length, Diagnostics._0_expected, "{");
24566
+ return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, Diagnostics._0_expected, "{");
24570
24567
}
24571
24568
else if (accessor.body && hasModifier(accessor, ModifierFlags.Abstract)) {
24572
24569
return grammarErrorOnNode(accessor, Diagnostics.An_abstract_accessor_cannot_have_an_implementation);
@@ -24631,7 +24628,7 @@ namespace ts {
24631
24628
return true;
24632
24629
}
24633
24630
else if (node.body === undefined) {
24634
- return grammarErrorAtPos(getSourceFileOfNode( node) , node.end - 1, ";".length, Diagnostics._0_expected, "{");
24631
+ return grammarErrorAtPos(node, node.end - 1, ";".length, Diagnostics._0_expected, "{");
24635
24632
}
24636
24633
}
24637
24634
@@ -24723,7 +24720,7 @@ namespace ts {
24723
24720
24724
24721
if (node.initializer) {
24725
24722
// Error on equals token which immediately precedes the initializer
24726
- return grammarErrorAtPos(getSourceFileOfNode( node) , node.initializer.pos - 1, 1, Diagnostics.A_rest_element_cannot_have_an_initializer);
24723
+ return grammarErrorAtPos(node, node.initializer.pos - 1, 1, Diagnostics.A_rest_element_cannot_have_an_initializer);
24727
24724
}
24728
24725
}
24729
24726
}
@@ -24746,15 +24743,13 @@ namespace ts {
24746
24743
else {
24747
24744
// Error on equals token which immediate precedes the initializer
24748
24745
const equalsTokenLength = "=".length;
24749
- return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength,
24750
- equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
24746
+ return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
24751
24747
}
24752
24748
}
24753
24749
if (node.initializer && !(isConst(node) && isStringOrNumberLiteralExpression(node.initializer))) {
24754
24750
// Error on equals token which immediate precedes the initializer
24755
24751
const equalsTokenLength = "=".length;
24756
- return grammarErrorAtPos(getSourceFileOfNode(node), node.initializer.pos - equalsTokenLength,
24757
- equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
24752
+ return grammarErrorAtPos(node, node.initializer.pos - equalsTokenLength, equalsTokenLength, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
24758
24753
}
24759
24754
}
24760
24755
else if (!node.initializer) {
@@ -24823,7 +24818,7 @@ namespace ts {
24823
24818
}
24824
24819
24825
24820
if (!declarationList.declarations.length) {
24826
- return grammarErrorAtPos(getSourceFileOfNode( declarationList) , declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty);
24821
+ return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty);
24827
24822
}
24828
24823
}
24829
24824
@@ -24876,7 +24871,8 @@ namespace ts {
24876
24871
}
24877
24872
}
24878
24873
24879
- function grammarErrorAtPos(sourceFile: SourceFile, start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
24874
+ function grammarErrorAtPos(nodeForSourceFile: Node, start: number, length: number, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
24875
+ const sourceFile = getSourceFileOfNode(nodeForSourceFile);
24880
24876
if (!hasParseDiagnostics(sourceFile)) {
24881
24877
diagnostics.add(createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2));
24882
24878
return true;
@@ -24893,7 +24889,7 @@ namespace ts {
24893
24889
24894
24890
function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) {
24895
24891
if (node.typeParameters) {
24896
- return grammarErrorAtPos(getSourceFileOfNode( node) , node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
24892
+ return grammarErrorAtPos(node, node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
24897
24893
}
24898
24894
}
24899
24895
0 commit comments