8000 fix(typescript-estree): visit typeParameters in OptionalCallExpr (#1377) · invalidred/typescript-eslint@cba6a2a · GitHub
[go: up one dir, main page]

Skip to content

Commit cba6a2a

Browse files
armano2bradzacher
authored andcommitted
fix(typescript-estree): visit typeParameters in OptionalCallExpr (typescript-eslint#1377)
1 parent f40639e commit cba6a2a

File tree

7 files changed

+729
-5
lines changed

7 files changed

+729
-5
lines changed

packages/parser/tests/lib/__snapshots__/typescript.ts.snap

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40807,6 +40807,105 @@ Object {
4080740807
}
4080840808
`;
4080940809

40810+
exports[`typescript fixtures/expressions/optional-call-expression-type-arguments.src 1`] = `
40811+
Object {
40812+
"$id": 3,
40813+
"block": Object {
40814+
"range": Array [
40815+
0,
40816+
35,
40817+
],
40818+
"type": "Program",
40819+
},
40820+
"childScopes": Array [
40821+
Object {
40822+
"$id": 2,
40823+
"block": Object {
40824+
"range": Array [
40825+
0,
40826+
35,
40827+
],
40828+
"type": "Program",
40829+
},
40830+
"childScopes": Array [],
40831+
"functionExpressionScope": false,
40832+
"isStrict": true,
40833+
"references": Array [
40834+
Object {
40835+
"$id": 0,
40836+
"from": Object {
40837+
"$ref": 2,
40838+
},
40839+
"identifier": Object {
40840+
"name": "foo",
40841+
"range": Array [
40842+
0,
40843+
3,
40844+
],
40845+
"type": "Identifier",
40846+
},
40847+
"kind": "r",
40848+
"resolved": null,
40849+
"writeExpr": undefined,
40850+
},
40851+
Object {
40852+
"$id": 1,
40853+
"from": Object {
40854+
"$ref": 2,
40855+
},
40856+
"identifier": Object {
40857+
"name": "foo",
40858+
"range": Array [
40859+
15,
40860+
18,
40861+
],
40862+
"type": "Identifier",
40863+
},
40864+
"kind": "r",
40865+
"resolved": null,
40866+
"writeExpr": undefined,
40867+
},
40868+
],
40869+
"throughReferences": Array [
40870+
Object {
40871+
"$ref": 0,
40872+
},
40873+
Object {
40874+
"$ref": 1,
40875+
},
40876+
],
40877+
"type": "module",
40878+
"upperScope": Object {
40879+
"$ref": 3,
40880+
},
40881+
"variableMap": Object {},
40882+
"variableScope": Object {
40883+
"$ref": 2,
40884+
},
40885+
"variables": Array [],
40886+
},
40887+
],
40888+
"functionExpressionScope": false,
40889+
"isStrict": false,
40890+
"references": Array [],
40891+
"throughReferences": Array [
40892+
Object {
40893+
"$ref": 0,
40894+
},
40895+
Object {
40896+
"$ref": 1,
40897+
},
40898+
],
40899+
"type": "global",
40900+
"upperScope": null,
40901+
"variableMap": Object {},
40902+
"variableScope": Object {
40903+
"$ref": 3,
40904+
},
40905+
"variables": Array [],
40906+
}
40907+
`;
40908+
4081040909
exports[`typescript fixtures/expressions/tagged-template-expression-type-arguments.src 1`] = `
4081140910
Object {
4081240911
"$id": 2,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
foo?.bar<A>();
2+
foo?.bar<number>();

packages/typescript-estree/src/create-program/createDefaultProgram.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const log = debug('typescript-eslint:typescript-estree:createDefaultProgram');
1212

1313
/**
1414
* @param code The code of the file being linted
15-
* @param options The config object
15+
* @param extra The config object
1616
* @param extra.tsconfigRootDir The root directory for relative tsconfig paths
1717
* @param extra.projects Provided tsconfig paths
1818
* @returns If found, returns the source file corresponding to the code and the containing program

packages/typescript-estree/src/parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ interface ASTAndProgram {
5151

5252
/**
5353
* @param code The code of the file being linted
54-
* @param options The config object
55-
* @param shouldProvideParserServices True iff the program should be attempted to be calculated from provided tsconfig files
54+
* @param shouldProvideParserServices True if the program should be attempted to be calculated from provided tsconfig files
55+
* @param shouldCreateDefaultProgram True if the program should be created from compiler host
5656
* @returns Returns a source file and program corresponding to the linted code
5757
*/
5858
function getProgramAndAST(
@@ -366,7 +366,7 @@ function parseAndGenerateServices<T extends TSESTreeOptions = TSESTreeOptions>(
366366
)!;
367367

368368
/**
369-
* Determine whether or not two-way maps of converted AST nodes should be preserved
369+
* Determine whatever or not two-way maps of converted AST nodes should be preserved
370370
* during the conversion process
371371
*/
372372
const shouldPreserveNodeMaps =

packages/typescript-estree/src/visitor-keys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const visitorKeys = eslintVisitorKeys.unionWith({
4343
BigIntLiteral: [],
4444
ClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
4545
Decorator: ['expression'],
46-
OptionalCallExpression: eslintVisitorKeys.KEYS.CallExpression,
46+
OptionalCallExpression: ['callee', 'typeParameters', 'arguments'],
4747
OptionalMemberExpression: eslintVisitorKeys.KEYS.MemberExpression,
4848
TSAbstractClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
4949
TSAbstractKeyword: [],

packages/typescript-estree/tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,6 +2502,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e
25022502

25032503
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/expressions/new-expression-type-arguments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
25042504

2505+
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/expressions/optional-call-expression-type-arguments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
2506+
25052507
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/expressions/tagged-template-expression-type-arguments.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
25062508

25072509
exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/namespaces-and-modules/ambient-module-declaration-with-import.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

0 commit comments

Comments
 (0)
0