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