Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing intrinsic keyword node to AST #3081

Merged
merged 2 commits into from Feb 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -49,6 +49,7 @@ function getGroup(node: TSESTree.TypeNode): Group {
case AST_NODE_TYPES.TSSymbolKeyword:
case AST_NODE_TYPES.TSThisType:
case AST_NODE_TYPES.TSUnknownKeyword:
case AST_NODE_TYPES.TSIntrinsicKeyword:
return Group.keyword;

case AST_NODE_TYPES.TSNullKeyword:
Expand Down
Expand Up @@ -43,10 +43,13 @@ const valid = (operator: '|' | '&'): TSESLint.ValidTestCase<Options>[] => [
type T =
${operator} A
${operator} B
${operator} intrinsic
${operator} number[]
${operator} string[]
${operator} any
${operator} string
${operator} symbol
${operator} this
${operator} readonly number[]
${operator} readonly string[]
${operator} 'a'
Expand Down
@@ -0,0 +1,4 @@
type Uppercase<S extends string> = intrinsic;
type Lowercase<S extends string> = intrinsic;
type Capitalize<S extends string> = intrinsic;
type Uncapitalize<S extends string> = intrinsic;
1 change: 1 addition & 0 deletions packages/types/src/ast-node-types.ts
Expand Up @@ -118,6 +118,7 @@ enum AST_NODE_TYPES {
TSInterfaceDeclaration = 'TSInterfaceDeclaration',
TSInterfaceHeritage = 'TSInterfaceHeritage',
TSIntersectionType = 'TSIntersectionType',
TSIntrinsicKeyword = 'TSIntrinsicKeyword',
TSLiteralType = 'TSLiteralType',
TSMappedType = 'TSMappedType',
TSMethodSignature = 'TSMethodSignature',
Expand Down
6 changes: 6 additions & 0 deletions packages/types/src/ts-estree.ts
Expand Up @@ -249,6 +249,7 @@ export type Node =
| TSInterfaceDeclaration
| TSInterfaceHeritage
| TSIntersectionType
| TSIntrinsicKeyword
| TSLiteralType
| TSMappedType
| TSMethodSignature
Expand Down Expand Up @@ -544,6 +545,7 @@ export type TypeNode =
| TSInferType
| TSInterfaceHeritage
| TSIntersectionType
| TSIntrinsicKeyword
| TSLiteralType
| TSMappedType
| TSNamedTupleMember
Expand Down Expand Up @@ -1469,6 +1471,10 @@ export interface TSIntersectionType extends BaseNode {
types: TypeNode[];
}

export interface TSIntrinsicKeyword extends BaseNode {
type: AST_NODE_TYPES.TSIntrinsicKeyword;
}

export interface TSLiteralType extends BaseNode {
type: AST_NODE_TYPES.TSLiteralType;
literal: LiteralExpression | UnaryExpression | UpdateExpression;
Expand Down
3 changes: 2 additions & 1 deletion packages/typescript-estree/src/convert.ts
Expand Up @@ -2206,7 +2206,8 @@ export class Converter {
case SyntaxKind.SymbolKeyword:
case SyntaxKind.UnknownKeyword:
case SyntaxKind.VoidKeyword:
case SyntaxKind.UndefinedKeyword: {
case SyntaxKind.UndefinedKeyword:
case SyntaxKind.IntrinsicKeyword: {
return this.createNode<any>(node, {
type: AST_NODE_TYPES[`TS${SyntaxKind[node.kind]}` as AST_NODE_TYPES],
});
Expand Down
Expand Up @@ -254,6 +254,7 @@ export interface EstreeToTsNodeTypes {
[AST_NODE_TYPES.TSAnyKeyword]: ts.KeywordTypeNode;
[AST_NODE_TYPES.TSBigIntKeyword]: ts.KeywordTypeNode;
[AST_NODE_TYPES.TSBooleanKeyword]: ts.KeywordTypeNode;
[AST_NODE_TYPES.TSIntrinsicKeyword]: ts.KeywordTypeNode;
[AST_NODE_TYPES.TSNeverKeyword]: ts.KeywordTypeNode;
[AST_NODE_TYPES.TSNumberKeyword]: ts.KeywordTypeNode;
[AST_NODE_TYPES.TSObjectKeyword]: ts.KeywordTypeNode;
Expand Down
Expand Up @@ -1993,6 +1993,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" e

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

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

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

exports[`Parse all fixtures with "errorOnTypeScriptSyntacticAndSemanticIssues" enabled fixtures/typescript/basics/keyword-variables.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
Expand Down