Skip to content

Commit

Permalink
fix: add missing intrinsic keyword node to AST (#3081)
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 committed Feb 21, 2021
1 parent 0469102 commit 409bf0b
Show file tree
Hide file tree
Showing 10 changed files with 1,264 additions and 1 deletion.
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

0 comments on commit 409bf0b

Please sign in to comment.