0
# AST Node Types
1
2
Comprehensive enumeration of all Abstract Syntax Tree node types for JavaScript and TypeScript, enabling type-safe node identification and processing throughout the typescript-eslint ecosystem.
3
4
## Capabilities
5
6
### AST_NODE_TYPES Enum
7
8
The complete enumeration of all AST node types supported by TypeScript-ESTree.
9
10
```typescript { .api }
11
enum AST_NODE_TYPES {
12
// Core JavaScript nodes
13
AccessorProperty = 'AccessorProperty',
14
ArrayExpression = 'ArrayExpression',
15
ArrayPattern = 'ArrayPattern',
16
ArrowFunctionExpression = 'ArrowFunctionExpression',
17
AssignmentExpression = 'AssignmentExpression',
18
AssignmentPattern = 'AssignmentPattern',
19
AwaitExpression = 'AwaitExpression',
20
BinaryExpression = 'BinaryExpression',
21
BlockStatement = 'BlockStatement',
22
BreakStatement = 'BreakStatement',
23
CallExpression = 'CallExpression',
24
CatchClause = 'CatchClause',
25
ChainExpression = 'ChainExpression',
26
ClassBody = 'ClassBody',
27
ClassDeclaration = 'ClassDeclaration',
28
ClassExpression = 'ClassExpression',
29
ConditionalExpression = 'ConditionalExpression',
30
ContinueStatement = 'ContinueStatement',
31
DebuggerStatement = 'DebuggerStatement',
32
Decorator = 'Decorator',
33
DoWhileStatement = 'DoWhileStatement',
34
EmptyStatement = 'EmptyStatement',
35
ExportAllDeclaration = 'ExportAllDeclaration',
36
ExportDefaultDeclaration = 'ExportDefaultDeclaration',
37
ExportNamedDeclaration = 'ExportNamedDeclaration',
38
ExportSpecifier = 'ExportSpecifier',
39
ExpressionStatement = 'ExpressionStatement',
40
ForInStatement = 'ForInStatement',
41
ForOfStatement = 'ForOfStatement',
42
ForStatement = 'ForStatement',
43
FunctionDeclaration = 'FunctionDeclaration',
44
FunctionExpression = 'FunctionExpression',
45
Identifier = 'Identifier',
46
IfStatement = 'IfStatement',
47
ImportAttribute = 'ImportAttribute',
48
ImportDeclaration = 'ImportDeclaration',
49
ImportDefaultSpecifier = 'ImportDefaultSpecifier',
50
ImportExpression = 'ImportExpression',
51
ImportNamespaceSpecifier = 'ImportNamespaceSpecifier',
52
ImportSpecifier = 'ImportSpecifier',
53
LabeledStatement = 'LabeledStatement',
54
Literal = 'Literal',
55
LogicalExpression = 'LogicalExpression',
56
MemberExpression = 'MemberExpression',
57
MetaProperty = 'MetaProperty',
58
MethodDefinition = 'MethodDefinition',
59
NewExpression = 'NewExpression',
60
ObjectExpression = 'ObjectExpression',
61
ObjectPattern = 'ObjectPattern',
62
PrivateIdentifier = 'PrivateIdentifier',
63
Program = 'Program',
64
Property = 'Property',
65
PropertyDefinition = 'PropertyDefinition',
66
RestElement = 'RestElement',
67
ReturnStatement = 'ReturnStatement',
68
SequenceExpression = 'SequenceExpression',
69
SpreadElement = 'SpreadElement',
70
StaticBlock = 'StaticBlock',
71
Super = 'Super',
72
SwitchCase = 'SwitchCase',
73
SwitchStatement = 'SwitchStatement',
74
TaggedTemplateExpression = 'TaggedTemplateExpression',
75
TemplateElement = 'TemplateElement',
76
TemplateLiteral = 'TemplateLiteral',
77
ThisExpression = 'ThisExpression',
78
ThrowStatement = 'ThrowStatement',
79
TryStatement = 'TryStatement',
80
UnaryExpression = 'UnaryExpression',
81
UpdateExpression = 'UpdateExpression',
82
VariableDeclaration = 'VariableDeclaration',
83
VariableDeclarator = 'VariableDeclarator',
84
WhileStatement = 'WhileStatement',
85
WithStatement = 'WithStatement',
86
YieldExpression = 'YieldExpression',
87
88
// JSX nodes
89
JSXAttribute = 'JSXAttribute',
90
JSXClosingElement = 'JSXClosingElement',
91
JSXClosingFragment = 'JSXClosingFragment',
92
JSXElement = 'JSXElement',
93
JSXEmptyExpression = 'JSXEmptyExpression',
94
JSXExpressionContainer = 'JSXExpressionContainer',
95
JSXFragment = 'JSXFragment',
96
JSXIdentifier = 'JSXIdentifier',
97
JSXMemberExpression = 'JSXMemberExpression',
98
JSXNamespacedName = 'JSXNamespacedName',
99
JSXOpeningElement = 'JSXOpeningElement',
100
JSXOpeningFragment = 'JSXOpeningFragment',
101
JSXSpreadAttribute = 'JSXSpreadAttribute',
102
JSXSpreadChild = 'JSXSpreadChild',
103
JSXText = 'JSXText',
104
105
// TypeScript-specific nodes
106
TSAbstractAccessorProperty = 'TSAbstractAccessorProperty',
107
TSAbstractKeyword = 'TSAbstractKeyword',
108
TSAbstractMethodDefinition = 'TSAbstractMethodDefinition',
109
TSAbstractPropertyDefinition = 'TSAbstractPropertyDefinition',
110
TSAnyKeyword = 'TSAnyKeyword',
111
TSArrayType = 'TSArrayType',
112
TSAsExpression = 'TSAsExpression',
113
TSAsyncKeyword = 'TSAsyncKeyword',
114
TSBigIntKeyword = 'TSBigIntKeyword',
115
TSBooleanKeyword = 'TSBooleanKeyword',
116
TSCallSignatureDeclaration = 'TSCallSignatureDeclaration',
117
TSClassImplements = 'TSClassImplements',
118
TSConditionalType = 'TSConditionalType',
119
TSConstructorType = 'TSConstructorType',
120
TSConstructSignatureDeclaration = 'TSConstructSignatureDeclaration',
121
TSDeclareFunction = 'TSDeclareFunction',
122
TSDeclareKeyword = 'TSDeclareKeyword',
123
TSEmptyBodyFunctionExpression = 'TSEmptyBodyFunctionExpression',
124
TSEnumBody = 'TSEnumBody',
125
TSEnumDeclaration = 'TSEnumDeclaration',
126
TSEnumMember = 'TSEnumMember',
127
TSExportAssignment = 'TSExportAssignment',
128
TSExportKeyword = 'TSExportKeyword',
129
TSExternalModuleReference = 'TSExternalModuleReference',
130
TSFunctionType = 'TSFunctionType',
131
TSImportEqualsDeclaration = 'TSImportEqualsDeclaration',
132
TSImportType = 'TSImportType',
133
TSIndexedAccessType = 'TSIndexedAccessType',
134
TSIndexSignature = 'TSIndexSignature',
135
TSInferType = 'TSInferType',
136
TSInstantiationExpression = 'TSInstantiationExpression',
137
TSInterfaceBody = 'TSInterfaceBody',
138
TSInterfaceDeclaration = 'TSInterfaceDeclaration',
139
TSInterfaceHeritage = 'TSInterfaceHeritage',
140
TSIntersectionType = 'TSIntersectionType',
141
TSIntrinsicKeyword = 'TSIntrinsicKeyword',
142
TSLiteralType = 'TSLiteralType',
143
TSMappedType = 'TSMappedType',
144
TSMethodSignature = 'TSMethodSignature',
145
TSModuleBlock = 'TSModuleBlock',
146
TSModuleDeclaration = 'TSModuleDeclaration',
147
TSNamedTupleMember = 'TSNamedTupleMember',
148
TSNamespaceExportDeclaration = 'TSNamespaceExportDeclaration',
149
TSNeverKeyword = 'TSNeverKeyword',
150
TSNonNullExpression = 'TSNonNullExpression',
151
TSNullKeyword = 'TSNullKeyword',
152
TSNumberKeyword = 'TSNumberKeyword',
153
TSObjectKeyword = 'TSObjectKeyword',
154
TSOptionalType = 'TSOptionalType',
155
TSParameterProperty = 'TSParameterProperty',
156
TSPrivateKeyword = 'TSPrivateKeyword',
157
TSPropertySignature = 'TSPropertySignature',
158
TSProtectedKeyword = 'TSProtectedKeyword',
159
TSPublicKeyword = 'TSPublicKeyword',
160
TSQualifiedName = 'TSQualifiedName',
161
TSReadonlyKeyword = 'TSReadonlyKeyword',
162
TSRestType = 'TSRestType',
163
TSSatisfiesExpression = 'TSSatisfiesExpression',
164
TSStaticKeyword = 'TSStaticKeyword',
165
TSStringKeyword = 'TSStringKeyword',
166
TSSymbolKeyword = 'TSSymbolKeyword',
167
TSTemplateLiteralType = 'TSTemplateLiteralType',
168
TSThisType = 'TSThisType',
169
TSTupleType = 'TSTupleType',
170
TSTypeAliasDeclaration = 'TSTypeAliasDeclaration',
171
TSTypeAnnotation = 'TSTypeAnnotation',
172
TSTypeAssertion = 'TSTypeAssertion',
173
TSTypeLiteral = 'TSTypeLiteral',
174
TSTypeOperator = 'TSTypeOperator',
175
TSTypeParameter = 'TSTypeParameter',
176
TSTypeParameterDeclaration = 'TSTypeParameterDeclaration',
177
TSTypeParameterInstantiation = 'TSTypeParameterInstantiation',
178
TSTypePredicate = 'TSTypePredicate',
179
TSTypeQuery = 'TSTypeQuery',
180
TSTypeReference = 'TSTypeReference',
181
TSUndefinedKeyword = 'TSUndefinedKeyword',
182
TSUnionType = 'TSUnionType',
183
TSUnknownKeyword = 'TSUnknownKeyword',
184
TSVoidKeyword = 'TSVoidKeyword',
185
}
186
```
187
188
**Usage Examples:**
189
190
```typescript
191
import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/types";
192
193
// Type-safe node identification
194
function processNode(node: TSESTree.Node): void {
195
switch (node.type) {
196
case AST_NODE_TYPES.FunctionDeclaration:
197
// TypeScript knows this is a FunctionDeclaration
198
console.log(`Function name: ${node.id?.name}`);
199
break;
200
201
case AST_NODE_TYPES.VariableDeclaration:
202
// TypeScript knows this is a VariableDeclaration
203
node.declarations.forEach(declarator => {
204
if (declarator.id.type === AST_NODE_TYPES.Identifier) {
205
console.log(`Variable: ${declarator.id.name}`);
206
}
207
});
208
break;
209
210
case AST_NODE_TYPES.TSInterfaceDeclaration:
211
// TypeScript-specific node handling
212
console.log(`Interface: ${node.id.name}`);
213
break;
214
}
215
}
216
217
// Check for TypeScript-specific nodes
218
function isTypeScriptNode(nodeType: AST_NODE_TYPES): boolean {
219
return nodeType.startsWith('TS');
220
}
221
222
// Group nodes by category
223
const STATEMENT_NODES = [
224
AST_NODE_TYPES.BlockStatement,
225
AST_NODE_TYPES.BreakStatement,
226
AST_NODE_TYPES.ContinueStatement,
227
AST_NODE_TYPES.DoWhileStatement,
228
AST_NODE_TYPES.ExpressionStatement,
229
AST_NODE_TYPES.ForStatement,
230
AST_NODE_TYPES.IfStatement,
231
AST_NODE_TYPES.ReturnStatement,
232
AST_NODE_TYPES.WhileStatement,
233
] as const;
234
```
235
236
## Node Categories
237
238
The AST node types can be organized into several logical categories:
239
240
### Core Language Constructs
241
- **Declarations**: `FunctionDeclaration`, `VariableDeclaration`, `ClassDeclaration`
242
- **Statements**: `IfStatement`, `ForStatement`, `WhileStatement`, `BlockStatement`
243
- **Expressions**: `BinaryExpression`, `CallExpression`, `MemberExpression`
244
- **Literals**: `Literal`, `TemplateLiteral`
245
- **Identifiers**: `Identifier`, `PrivateIdentifier`
246
247
### Modern JavaScript Features
248
- **Classes**: `ClassBody`, `MethodDefinition`, `PropertyDefinition`, `StaticBlock`
249
- **Modules**: `ImportDeclaration`, `ExportDeclaration`, `ImportSpecifier`
250
- **Async/Await**: `AwaitExpression`, `ArrowFunctionExpression`
251
- **Destructuring**: `ArrayPattern`, `ObjectPattern`, `RestElement`
252
253
### JSX Support
254
- **Elements**: `JSXElement`, `JSXFragment`, `JSXText`
255
- **Attributes**: `JSXAttribute`, `JSXSpreadAttribute`
256
- **Identifiers**: `JSXIdentifier`, `JSXMemberExpression`
257
258
### TypeScript Extensions
259
- **Type Annotations**: `TSTypeAnnotation`, `TSAsExpression`, `TSTypeAssertion`
260
- **Declarations**: `TSInterfaceDeclaration`, `TSTypeAliasDeclaration`, `TSEnumDeclaration`
261
- **Type System**: `TSUnionType`, `TSIntersectionType`, `TSMappedType`
262
- **Keywords**: `TSPublicKeyword`, `TSPrivateKeyword`, `TSReadonlyKeyword`