Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(typescript-estree): visit typeParameters in OptionalCallExpr (#1377)
  • Loading branch information
armano2 authored and bradzacher committed Dec 24, 2019
1 parent f40639e commit cba6a2a
Show file tree
Hide file tree
Showing 7 changed files with 729 additions and 5 deletions.
99 changes: 99 additions & 0 deletions packages/parser/tests/lib/__snapshots__/typescript.ts.snap
Expand Up @@ -40807,6 +40807,105 @@ Object {
}
`;

exports[`typescript fixtures/expressions/optional-call-expression-type-arguments.src 1`] = `
Object {
"$id": 3,
"block": Object {
"range": Array [
0,
35,
],
"type": "Program",
},
"childScopes": Array [
Object {
"$id": 2,
"block": Object {
"range": Array [
0,
35,
],
"type": "Program",
},
"childScopes": Array [],
"functionExpressionScope": false,
"isStrict": true,
"references": Array [
Object {
"$id": 0,
"from": Object {
"$ref": 2,
},
"identifier": Object {
"name": "foo",
"range": Array [
0,
3,
],
"type": "Identifier",
},
"kind": "r",
"resolved": null,
"writeExpr": undefined,
},
Object {
"$id": 1,
"from": Object {
"$ref": 2,
},
"identifier": Object {
"name": "foo",
"range": Array [
15,
18,
],
"type": "Identifier",
},
"kind": "r",
"resolved": null,
"writeExpr": undefined,
},
],
"throughReferences": Array [
Object {
"$ref": 0,
},
Object {
"$ref": 1,
},
],
"type": "module",
"upperScope": Object {
"$ref": 3,
},
"variableMap": Object {},
"variableScope": Object {
"$ref": 2,
},
"variables": Array [],
},
],
"functionExpressionScope": false,
"isStrict": false,
"references": Array [],
"throughReferences": Array [
Object {
"$ref": 0,
},
Object {
"$ref": 1,
},
],
"type": "global",
"upperScope": null,
"variableMap": Object {},
"variableScope": Object {
"$ref": 3,
},
"variables": Array [],
}
`;

exports[`typescript fixtures/expressions/tagged-template-expression-type-arguments.src 1`] = `
Object {
"$id": 2,
Expand Down
@@ -0,0 +1,2 @@
foo?.bar<A>();
foo?.bar<number>();
Expand Up @@ -12,7 +12,7 @@ const log = debug('typescript-eslint:typescript-estree:createDefaultProgram');

/**
* @param code The code of the file being linted
* @param options The config object
* @param extra The config object
* @param extra.tsconfigRootDir The root directory for relative tsconfig paths
* @param extra.projects Provided tsconfig paths
* @returns If found, returns the source file corresponding to the code and the containing program
Expand Down
6 changes: 3 additions & 3 deletions packages/typescript-estree/src/parser.ts
Expand Up @@ -51,8 +51,8 @@ interface ASTAndProgram {

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

/**
* Determine whether or not two-way maps of converted AST nodes should be preserved
* Determine whatever or not two-way maps of converted AST nodes should be preserved
* during the conversion process
*/
const shouldPreserveNodeMaps =
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript-estree/src/visitor-keys.ts
Expand Up @@ -43,7 +43,7 @@ export const visitorKeys = eslintVisitorKeys.unionWith({
BigIntLiteral: [],
ClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
Decorator: ['expression'],
OptionalCallExpression: eslintVisitorKeys.KEYS.CallExpression,
OptionalCallExpression: ['callee', 'typeParameters', 'arguments'],
OptionalMemberExpression: eslintVisitorKeys.KEYS.MemberExpression,
TSAbstractClassProperty: ['decorators', 'key', 'typeAnnotation', 'value'],
TSAbstractKeyword: [],
Expand Down
Expand Up @@ -2502,6 +2502,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e

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

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"`;

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"`;

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"`;
Expand Down

0 comments on commit cba6a2a

Please sign in to comment.