Skip to content

Commit

Permalink
feat: [TS4.7] support type parameters for typeof (#5067)
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed May 24, 2022
1 parent 38c44a8 commit 836de79
Show file tree
Hide file tree
Showing 6 changed files with 432 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ast-spec/src/type/TSTypeQuery/spec.ts
@@ -1,8 +1,10 @@
import type { AST_NODE_TYPES } from '../../ast-node-types';
import type { BaseNode } from '../../base/BaseNode';
import type { TSTypeParameterInstantiation } from '../../special/spec';
import type { EntityName } from '../../unions/EntityName';

export interface TSTypeQuery extends BaseNode {
type: AST_NODE_TYPES.TSTypeQuery;
exprName: EntityName;
typeParameters?: TSTypeParameterInstantiation;
}
@@ -0,0 +1 @@
let x: typeof y.z<w>;
3 changes: 3 additions & 0 deletions packages/typescript-estree/src/convert.ts
Expand Up @@ -2429,6 +2429,9 @@ export class Converter {
return this.createNode<TSESTree.TSTypeQuery>(node, {
type: AST_NODE_TYPES.TSTypeQuery,
exprName: this.convertType(node.exprName),
typeParameters:
node.typeArguments &&
this.convertTypeArgumentsToTypeParameters(node.typeArguments, node),
});
}

Expand Down
Expand Up @@ -2786,6 +2786,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/typeof.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

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

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/types/union-intersection.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

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

0 comments on commit 836de79

Please sign in to comment.