1 | import type { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/types';
|
2 | import type * as ts from 'typescript';
|
3 | import type { TSNode } from './ts-nodes';
|
4 | export interface EstreeToTsNodeTypes {
|
5 | [AST_NODE_TYPES.AccessorProperty]: ts.PropertyDeclaration;
|
6 | [AST_NODE_TYPES.ArrayExpression]: ts.ArrayLiteralExpression;
|
7 | [AST_NODE_TYPES.ArrayPattern]: ts.ArrayBindingPattern | ts.ArrayLiteralExpression;
|
8 | [AST_NODE_TYPES.ArrowFunctionExpression]: ts.ArrowFunction;
|
9 | [AST_NODE_TYPES.AssignmentExpression]: ts.BinaryExpression;
|
10 | [AST_NODE_TYPES.AssignmentPattern]: ts.BinaryExpression | ts.BindingElement | ts.ParameterDeclaration | ts.ShorthandPropertyAssignment;
|
11 | [AST_NODE_TYPES.AwaitExpression]: ts.AwaitExpression;
|
12 | [AST_NODE_TYPES.BinaryExpression]: ts.BinaryExpression;
|
13 | [AST_NODE_TYPES.BlockStatement]: ts.Block;
|
14 | [AST_NODE_TYPES.BreakStatement]: ts.BreakStatement;
|
15 | [AST_NODE_TYPES.CallExpression]: ts.CallExpression;
|
16 | [AST_NODE_TYPES.CatchClause]: ts.CatchClause;
|
17 | [AST_NODE_TYPES.ChainExpression]: ts.CallExpression | ts.ElementAccessExpression | ts.NonNullExpression | ts.PropertyAccessExpression;
|
18 | [AST_NODE_TYPES.ClassBody]: ts.ClassDeclaration | ts.ClassExpression;
|
19 | [AST_NODE_TYPES.ClassDeclaration]: ts.ClassDeclaration;
|
20 | [AST_NODE_TYPES.ClassExpression]: ts.ClassExpression;
|
21 | [AST_NODE_TYPES.PropertyDefinition]: ts.PropertyDeclaration;
|
22 | [AST_NODE_TYPES.ConditionalExpression]: ts.ConditionalExpression;
|
23 | [AST_NODE_TYPES.ContinueStatement]: ts.ContinueStatement;
|
24 | [AST_NODE_TYPES.DebuggerStatement]: ts.DebuggerStatement;
|
25 | [AST_NODE_TYPES.Decorator]: ts.Decorator;
|
26 | [AST_NODE_TYPES.DoWhileStatement]: ts.DoStatement;
|
27 | [AST_NODE_TYPES.EmptyStatement]: ts.EmptyStatement;
|
28 | [AST_NODE_TYPES.ExportAllDeclaration]: ts.ExportDeclaration;
|
29 | [AST_NODE_TYPES.ExportDefaultDeclaration]: ts.ClassDeclaration | ts.ClassExpression | ts.EnumDeclaration | ts.ExportAssignment | ts.FunctionDeclaration | ts.InterfaceDeclaration | ts.ModuleDeclaration | ts.TypeAliasDeclaration | ts.VariableStatement;
|
30 | [AST_NODE_TYPES.ExportNamedDeclaration]: ts.ClassDeclaration | ts.ClassExpression | ts.EnumDeclaration | ts.ExportDeclaration | ts.FunctionDeclaration | ts.ImportEqualsDeclaration | ts.InterfaceDeclaration | ts.ModuleDeclaration | ts.TypeAliasDeclaration | ts.VariableStatement;
|
31 | [AST_NODE_TYPES.ExportSpecifier]: ts.ExportSpecifier;
|
32 | [AST_NODE_TYPES.ExpressionStatement]: ts.ExpressionStatement;
|
33 | [AST_NODE_TYPES.ForInStatement]: ts.ForInStatement;
|
34 | [AST_NODE_TYPES.ForOfStatement]: ts.ForOfStatement;
|
35 | [AST_NODE_TYPES.ForStatement]: ts.ForStatement;
|
36 | [AST_NODE_TYPES.FunctionDeclaration]: ts.FunctionDeclaration;
|
37 | [AST_NODE_TYPES.FunctionExpression]: ts.ConstructorDeclaration | ts.FunctionExpression | ts.GetAccessorDeclaration | ts.MethodDeclaration | ts.SetAccessorDeclaration;
|
38 | [AST_NODE_TYPES.Identifier]: ts.ConstructorDeclaration | ts.Identifier | ts.Token<ts.SyntaxKind.ImportKeyword | ts.SyntaxKind.NewKeyword>;
|
39 | [AST_NODE_TYPES.PrivateIdentifier]: ts.PrivateIdentifier;
|
40 | [AST_NODE_TYPES.IfStatement]: ts.IfStatement;
|
41 | [AST_NODE_TYPES.ImportAttribute]: 'ImportAttribute' extends keyof typeof ts ? ts.ImportAttribute : ts.AssertEntry;
|
42 | [AST_NODE_TYPES.ImportDeclaration]: ts.ImportDeclaration;
|
43 | [AST_NODE_TYPES.ImportDefaultSpecifier]: ts.ImportClause;
|
44 | [AST_NODE_TYPES.ImportExpression]: ts.CallExpression;
|
45 | [AST_NODE_TYPES.ImportNamespaceSpecifier]: ts.NamespaceImport;
|
46 | [AST_NODE_TYPES.ImportSpecifier]: ts.ImportSpecifier;
|
47 | [AST_NODE_TYPES.JSXAttribute]: ts.JsxAttribute;
|
48 | [AST_NODE_TYPES.JSXClosingElement]: ts.JsxClosingElement;
|
49 | [AST_NODE_TYPES.JSXClosingFragment]: ts.JsxClosingFragment;
|
50 | [AST_NODE_TYPES.JSXElement]: ts.JsxElement | ts.JsxSelfClosingElement;
|
51 | [AST_NODE_TYPES.JSXEmptyExpression]: ts.JsxExpression;
|
52 | [AST_NODE_TYPES.JSXExpressionContainer]: ts.JsxExpression;
|
53 | [AST_NODE_TYPES.JSXFragment]: ts.JsxFragment;
|
54 | [AST_NODE_TYPES.JSXIdentifier]: ts.Identifier | ts.ThisExpression;
|
55 | [AST_NODE_TYPES.JSXOpeningElement]: ts.JsxOpeningElement | ts.JsxSelfClosingElement;
|
56 | [AST_NODE_TYPES.JSXOpeningFragment]: ts.JsxOpeningFragment;
|
57 | [AST_NODE_TYPES.JSXSpreadAttribute]: ts.JsxSpreadAttribute;
|
58 | [AST_NODE_TYPES.JSXSpreadChild]: ts.JsxExpression;
|
59 | [AST_NODE_TYPES.JSXMemberExpression]: ts.PropertyAccessExpression;
|
60 | [AST_NODE_TYPES.JSXNamespacedName]: ts.JsxNamespacedName;
|
61 | [AST_NODE_TYPES.JSXText]: ts.JsxText;
|
62 | [AST_NODE_TYPES.LabeledStatement]: ts.LabeledStatement;
|
63 | [AST_NODE_TYPES.Literal]: ts.BigIntLiteral | ts.BooleanLiteral | ts.NullLiteral | ts.NumericLiteral | ts.RegularExpressionLiteral | ts.StringLiteral;
|
64 | [AST_NODE_TYPES.LogicalExpression]: ts.BinaryExpression;
|
65 | [AST_NODE_TYPES.MemberExpression]: ts.ElementAccessExpression | ts.PropertyAccessExpression;
|
66 | [AST_NODE_TYPES.MetaProperty]: ts.MetaProperty;
|
67 | [AST_NODE_TYPES.MethodDefinition]: ts.ConstructorDeclaration | ts.GetAccessorDeclaration | ts.MethodDeclaration | ts.SetAccessorDeclaration;
|
68 | [AST_NODE_TYPES.NewExpression]: ts.NewExpression;
|
69 | [AST_NODE_TYPES.ObjectExpression]: ts.ObjectLiteralExpression;
|
70 | [AST_NODE_TYPES.ObjectPattern]: ts.ObjectBindingPattern | ts.ObjectLiteralExpression;
|
71 | [AST_NODE_TYPES.Program]: ts.SourceFile;
|
72 | [AST_NODE_TYPES.Property]: ts.BindingElement | ts.GetAccessorDeclaration | ts.MethodDeclaration | ts.PropertyAssignment | ts.SetAccessorDeclaration | ts.ShorthandPropertyAssignment;
|
73 | [AST_NODE_TYPES.RestElement]: ts.BindingElement | ts.ParameterDeclaration | ts.SpreadAssignment | ts.SpreadElement;
|
74 | [AST_NODE_TYPES.ReturnStatement]: ts.ReturnStatement;
|
75 | [AST_NODE_TYPES.SequenceExpression]: ts.BinaryExpression;
|
76 | [AST_NODE_TYPES.SpreadElement]: ts.SpreadAssignment | ts.SpreadElement;
|
77 | [AST_NODE_TYPES.StaticBlock]: ts.ClassStaticBlockDeclaration;
|
78 | [AST_NODE_TYPES.Super]: ts.SuperExpression;
|
79 | [AST_NODE_TYPES.SwitchCase]: ts.CaseClause | ts.DefaultClause;
|
80 | [AST_NODE_TYPES.SwitchStatement]: ts.SwitchStatement;
|
81 | [AST_NODE_TYPES.TaggedTemplateExpression]: ts.TaggedTemplateExpression;
|
82 | [AST_NODE_TYPES.TemplateElement]: ts.NoSubstitutionTemplateLiteral | ts.TemplateHead | ts.TemplateMiddle | ts.TemplateTail;
|
83 | [AST_NODE_TYPES.TemplateLiteral]: ts.NoSubstitutionTemplateLiteral | ts.TemplateExpression;
|
84 | [AST_NODE_TYPES.ThisExpression]: ts.Identifier | ts.KeywordTypeNode | ts.ThisExpression;
|
85 | [AST_NODE_TYPES.ThrowStatement]: ts.ThrowStatement;
|
86 | [AST_NODE_TYPES.TryStatement]: ts.TryStatement;
|
87 | [AST_NODE_TYPES.TSAbstractAccessorProperty]: ts.PropertyDeclaration;
|
88 | [AST_NODE_TYPES.TSAbstractPropertyDefinition]: ts.PropertyDeclaration;
|
89 | [AST_NODE_TYPES.TSAbstractMethodDefinition]: ts.ConstructorDeclaration | ts.GetAccessorDeclaration | ts.MethodDeclaration | ts.SetAccessorDeclaration;
|
90 | [AST_NODE_TYPES.TSArrayType]: ts.ArrayTypeNode;
|
91 | [AST_NODE_TYPES.TSAsExpression]: ts.AsExpression;
|
92 | [AST_NODE_TYPES.TSCallSignatureDeclaration]: ts.CallSignatureDeclaration;
|
93 | [AST_NODE_TYPES.TSClassImplements]: ts.ExpressionWithTypeArguments;
|
94 | [AST_NODE_TYPES.TSConditionalType]: ts.ConditionalTypeNode;
|
95 | [AST_NODE_TYPES.TSConstructorType]: ts.ConstructorTypeNode;
|
96 | [AST_NODE_TYPES.TSConstructSignatureDeclaration]: ts.ConstructSignatureDeclaration;
|
97 | [AST_NODE_TYPES.TSDeclareFunction]: ts.FunctionDeclaration;
|
98 | [AST_NODE_TYPES.TSEnumBody]: ts.EnumDeclaration;
|
99 | [AST_NODE_TYPES.TSEnumDeclaration]: ts.EnumDeclaration;
|
100 | [AST_NODE_TYPES.TSEnumMember]: ts.EnumMember;
|
101 | [AST_NODE_TYPES.TSExportAssignment]: ts.ExportAssignment;
|
102 | [AST_NODE_TYPES.TSExternalModuleReference]: ts.ExternalModuleReference;
|
103 | [AST_NODE_TYPES.TSFunctionType]: ts.FunctionTypeNode;
|
104 | [AST_NODE_TYPES.TSImportEqualsDeclaration]: ts.ImportEqualsDeclaration;
|
105 | [AST_NODE_TYPES.TSImportType]: ts.ImportTypeNode;
|
106 | [AST_NODE_TYPES.TSIndexedAccessType]: ts.IndexedAccessTypeNode;
|
107 | [AST_NODE_TYPES.TSIndexSignature]: ts.IndexSignatureDeclaration;
|
108 | [AST_NODE_TYPES.TSInferType]: ts.InferTypeNode;
|
109 | [AST_NODE_TYPES.TSInterfaceDeclaration]: ts.InterfaceDeclaration;
|
110 | [AST_NODE_TYPES.TSInterfaceBody]: ts.InterfaceDeclaration;
|
111 | [AST_NODE_TYPES.TSInterfaceHeritage]: ts.ExpressionWithTypeArguments;
|
112 | [AST_NODE_TYPES.TSIntersectionType]: ts.IntersectionTypeNode;
|
113 | [AST_NODE_TYPES.TSInstantiationExpression]: ts.ExpressionWithTypeArguments;
|
114 | [AST_NODE_TYPES.TSSatisfiesExpression]: ts.SatisfiesExpression;
|
115 | [AST_NODE_TYPES.TSLiteralType]: ts.LiteralTypeNode;
|
116 | [AST_NODE_TYPES.TSMappedType]: ts.MappedTypeNode;
|
117 | [AST_NODE_TYPES.TSMethodSignature]: ts.GetAccessorDeclaration | ts.MethodSignature | ts.SetAccessorDeclaration;
|
118 | [AST_NODE_TYPES.TSModuleBlock]: ts.ModuleBlock;
|
119 | [AST_NODE_TYPES.TSModuleDeclaration]: ts.ModuleDeclaration;
|
120 | [AST_NODE_TYPES.TSNamedTupleMember]: ts.NamedTupleMember;
|
121 | [AST_NODE_TYPES.TSNamespaceExportDeclaration]: ts.NamespaceExportDeclaration;
|
122 | [AST_NODE_TYPES.TSNonNullExpression]: ts.NonNullExpression;
|
123 | [AST_NODE_TYPES.TSOptionalType]: ts.OptionalTypeNode;
|
124 | [AST_NODE_TYPES.TSParameterProperty]: ts.ParameterDeclaration;
|
125 | [AST_NODE_TYPES.TSPropertySignature]: ts.PropertySignature;
|
126 | [AST_NODE_TYPES.TSQualifiedName]: ts.Identifier | ts.QualifiedName;
|
127 | [AST_NODE_TYPES.TSRestType]: ts.NamedTupleMember | ts.RestTypeNode;
|
128 | [AST_NODE_TYPES.TSThisType]: ts.ThisTypeNode;
|
129 | [AST_NODE_TYPES.TSTupleType]: ts.TupleTypeNode;
|
130 | [AST_NODE_TYPES.TSTemplateLiteralType]: ts.TemplateLiteralTypeNode;
|
131 | [AST_NODE_TYPES.TSTypeAliasDeclaration]: ts.TypeAliasDeclaration;
|
132 | [AST_NODE_TYPES.TSTypeAnnotation]: undefined;
|
133 | [AST_NODE_TYPES.TSTypeAssertion]: ts.TypeAssertion;
|
134 | [AST_NODE_TYPES.TSTypeLiteral]: ts.TypeLiteralNode;
|
135 | [AST_NODE_TYPES.TSTypeOperator]: ts.TypeOperatorNode;
|
136 | [AST_NODE_TYPES.TSTypeParameter]: ts.TypeParameterDeclaration;
|
137 | [AST_NODE_TYPES.TSTypeParameterDeclaration]: undefined;
|
138 | [AST_NODE_TYPES.TSTypeParameterInstantiation]: ts.CallExpression | ts.ExpressionWithTypeArguments | ts.ImportTypeNode | ts.JsxOpeningElement | ts.JsxSelfClosingElement | ts.NewExpression | ts.TaggedTemplateExpression | ts.TypeQueryNode | ts.TypeReferenceNode;
|
139 | [AST_NODE_TYPES.TSTypePredicate]: ts.TypePredicateNode;
|
140 | [AST_NODE_TYPES.TSTypeQuery]: ts.ImportTypeNode | ts.TypeQueryNode;
|
141 | [AST_NODE_TYPES.TSTypeReference]: ts.TypeReferenceNode;
|
142 | [AST_NODE_TYPES.TSUnionType]: ts.UnionTypeNode;
|
143 | [AST_NODE_TYPES.UpdateExpression]: ts.PostfixUnaryExpression | ts.PrefixUnaryExpression;
|
144 | [AST_NODE_TYPES.UnaryExpression]: ts.DeleteExpression | ts.PostfixUnaryExpression | ts.PrefixUnaryExpression | ts.TypeOfExpression | ts.VoidExpression;
|
145 | [AST_NODE_TYPES.VariableDeclaration]: ts.VariableDeclarationList | ts.VariableStatement;
|
146 | [AST_NODE_TYPES.VariableDeclarator]: ts.VariableDeclaration;
|
147 | [AST_NODE_TYPES.WhileStatement]: ts.WhileStatement;
|
148 | [AST_NODE_TYPES.WithStatement]: ts.WithStatement;
|
149 | [AST_NODE_TYPES.YieldExpression]: ts.YieldExpression;
|
150 | [AST_NODE_TYPES.TSEmptyBodyFunctionExpression]: ts.ConstructorDeclaration | ts.FunctionExpression | ts.GetAccessorDeclaration | ts.MethodDeclaration | ts.SetAccessorDeclaration;
|
151 | [AST_NODE_TYPES.TSAbstractKeyword]: ts.Token<ts.SyntaxKind.AbstractKeyword>;
|
152 | [AST_NODE_TYPES.TSNullKeyword]: ts.KeywordTypeNode | ts.NullLiteral;
|
153 | [AST_NODE_TYPES.TSAnyKeyword]: ts.KeywordTypeNode;
|
154 | [AST_NODE_TYPES.TSBigIntKeyword]: ts.KeywordTypeNode;
|
155 | [AST_NODE_TYPES.TSBooleanKeyword]: ts.KeywordTypeNode;
|
156 | [AST_NODE_TYPES.TSIntrinsicKeyword]: ts.KeywordTypeNode;
|
157 | [AST_NODE_TYPES.TSNeverKeyword]: ts.KeywordTypeNode;
|
158 | [AST_NODE_TYPES.TSNumberKeyword]: ts.KeywordTypeNode;
|
159 | [AST_NODE_TYPES.TSObjectKeyword]: ts.KeywordTypeNode;
|
160 | [AST_NODE_TYPES.TSStringKeyword]: ts.KeywordTypeNode;
|
161 | [AST_NODE_TYPES.TSSymbolKeyword]: ts.KeywordTypeNode;
|
162 | [AST_NODE_TYPES.TSUnknownKeyword]: ts.KeywordTypeNode;
|
163 | [AST_NODE_TYPES.TSVoidKeyword]: ts.KeywordTypeNode;
|
164 | [AST_NODE_TYPES.TSUndefinedKeyword]: ts.KeywordTypeNode;
|
165 | [AST_NODE_TYPES.TSAsyncKeyword]: ts.Token<ts.SyntaxKind.AsyncKeyword>;
|
166 | [AST_NODE_TYPES.TSDeclareKeyword]: ts.Token<ts.SyntaxKind.DeclareKeyword>;
|
167 | [AST_NODE_TYPES.TSExportKeyword]: ts.Token<ts.SyntaxKind.ExportKeyword>;
|
168 | [AST_NODE_TYPES.TSStaticKeyword]: ts.Token<ts.SyntaxKind.StaticKeyword>;
|
169 | [AST_NODE_TYPES.TSPublicKeyword]: ts.Token<ts.SyntaxKind.PublicKeyword>;
|
170 | [AST_NODE_TYPES.TSPrivateKeyword]: ts.Token<ts.SyntaxKind.PrivateKeyword>;
|
171 | [AST_NODE_TYPES.TSProtectedKeyword]: ts.Token<ts.SyntaxKind.ProtectedKeyword>;
|
172 | [AST_NODE_TYPES.TSReadonlyKeyword]: ts.Token<ts.SyntaxKind.ReadonlyKeyword>;
|
173 | }
|
174 |
|
175 |
|
176 |
|
177 |
|
178 | export type TSESTreeToTSNode<T extends TSESTree.Node = TSESTree.Node> = Extract<ts.Token<ts.SyntaxKind.ImportKeyword | ts.SyntaxKind.NewKeyword> | TSNode, EstreeToTsNodeTypes[T['type']]>;
|
179 |
|
\ | No newline at end of file |