Type definitions for the TypeScript-ESTree AST specification, including parser options and AST node types
—
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.
The complete enumeration of all AST node types supported by TypeScript-ESTree.
enum AST_NODE_TYPES {
// Core JavaScript nodes
AccessorProperty = 'AccessorProperty',
ArrayExpression = 'ArrayExpression',
ArrayPattern = 'ArrayPattern',
ArrowFunctionExpression = 'ArrowFunctionExpression',
AssignmentExpression = 'AssignmentExpression',
AssignmentPattern = 'AssignmentPattern',
AwaitExpression = 'AwaitExpression',
BinaryExpression = 'BinaryExpression',
BlockStatement = 'BlockStatement',
BreakStatement = 'BreakStatement',
CallExpression = 'CallExpression',
CatchClause = 'CatchClause',
ChainExpression = 'ChainExpression',
ClassBody = 'ClassBody',
ClassDeclaration = 'ClassDeclaration',
ClassExpression = 'ClassExpression',
ConditionalExpression = 'ConditionalExpression',
ContinueStatement = 'ContinueStatement',
DebuggerStatement = 'DebuggerStatement',
Decorator = 'Decorator',
DoWhileStatement = 'DoWhileStatement',
EmptyStatement = 'EmptyStatement',
ExportAllDeclaration = 'ExportAllDeclaration',
ExportDefaultDeclaration = 'ExportDefaultDeclaration',
ExportNamedDeclaration = 'ExportNamedDeclaration',
ExportSpecifier = 'ExportSpecifier',
ExpressionStatement = 'ExpressionStatement',
ForInStatement = 'ForInStatement',
ForOfStatement = 'ForOfStatement',
ForStatement = 'ForStatement',
FunctionDeclaration = 'FunctionDeclaration',
FunctionExpression = 'FunctionExpression',
Identifier = 'Identifier',
IfStatement = 'IfStatement',
ImportAttribute = 'ImportAttribute',
ImportDeclaration = 'ImportDeclaration',
ImportDefaultSpecifier = 'ImportDefaultSpecifier',
ImportExpression = 'ImportExpression',
ImportNamespaceSpecifier = 'ImportNamespaceSpecifier',
ImportSpecifier = 'ImportSpecifier',
LabeledStatement = 'LabeledStatement',
Literal = 'Literal',
LogicalExpression = 'LogicalExpression',
MemberExpression = 'MemberExpression',
MetaProperty = 'MetaProperty',
MethodDefinition = 'MethodDefinition',
NewExpression = 'NewExpression',
ObjectExpression = 'ObjectExpression',
ObjectPattern = 'ObjectPattern',
PrivateIdentifier = 'PrivateIdentifier',
Program = 'Program',
Property = 'Property',
PropertyDefinition = 'PropertyDefinition',
RestElement = 'RestElement',
ReturnStatement = 'ReturnStatement',
SequenceExpression = 'SequenceExpression',
SpreadElement = 'SpreadElement',
StaticBlock = 'StaticBlock',
Super = 'Super',
SwitchCase = 'SwitchCase',
SwitchStatement = 'SwitchStatement',
TaggedTemplateExpression = 'TaggedTemplateExpression',
TemplateElement = 'TemplateElement',
TemplateLiteral = 'TemplateLiteral',
ThisExpression = 'ThisExpression',
ThrowStatement = 'ThrowStatement',
TryStatement = 'TryStatement',
UnaryExpression = 'UnaryExpression',
UpdateExpression = 'UpdateExpression',
VariableDeclaration = 'VariableDeclaration',
VariableDeclarator = 'VariableDeclarator',
WhileStatement = 'WhileStatement',
WithStatement = 'WithStatement',
YieldExpression = 'YieldExpression',
// JSX nodes
JSXAttribute = 'JSXAttribute',
JSXClosingElement = 'JSXClosingElement',
JSXClosingFragment = 'JSXClosingFragment',
JSXElement = 'JSXElement',
JSXEmptyExpression = 'JSXEmptyExpression',
JSXExpressionContainer = 'JSXExpressionContainer',
JSXFragment = 'JSXFragment',
JSXIdentifier = 'JSXIdentifier',
JSXMemberExpression = 'JSXMemberExpression',
JSXNamespacedName = 'JSXNamespacedName',
JSXOpeningElement = 'JSXOpeningElement',
JSXOpeningFragment = 'JSXOpeningFragment',
JSXSpreadAttribute = 'JSXSpreadAttribute',
JSXSpreadChild = 'JSXSpreadChild',
JSXText = 'JSXText',
// TypeScript-specific nodes
TSAbstractAccessorProperty = 'TSAbstractAccessorProperty',
TSAbstractKeyword = 'TSAbstractKeyword',
TSAbstractMethodDefinition = 'TSAbstractMethodDefinition',
TSAbstractPropertyDefinition = 'TSAbstractPropertyDefinition',
TSAnyKeyword = 'TSAnyKeyword',
TSArrayType = 'TSArrayType',
TSAsExpression = 'TSAsExpression',
TSAsyncKeyword = 'TSAsyncKeyword',
TSBigIntKeyword = 'TSBigIntKeyword',
TSBooleanKeyword = 'TSBooleanKeyword',
TSCallSignatureDeclaration = 'TSCallSignatureDeclaration',
TSClassImplements = 'TSClassImplements',
TSConditionalType = 'TSConditionalType',
TSConstructorType = 'TSConstructorType',
TSConstructSignatureDeclaration = 'TSConstructSignatureDeclaration',
TSDeclareFunction = 'TSDeclareFunction',
TSDeclareKeyword = 'TSDeclareKeyword',
TSEmptyBodyFunctionExpression = 'TSEmptyBodyFunctionExpression',
TSEnumBody = 'TSEnumBody',
TSEnumDeclaration = 'TSEnumDeclaration',
TSEnumMember = 'TSEnumMember',
TSExportAssignment = 'TSExportAssignment',
TSExportKeyword = 'TSExportKeyword',
TSExternalModuleReference = 'TSExternalModuleReference',
TSFunctionType = 'TSFunctionType',
TSImportEqualsDeclaration = 'TSImportEqualsDeclaration',
TSImportType = 'TSImportType',
TSIndexedAccessType = 'TSIndexedAccessType',
TSIndexSignature = 'TSIndexSignature',
TSInferType = 'TSInferType',
TSInstantiationExpression = 'TSInstantiationExpression',
TSInterfaceBody = 'TSInterfaceBody',
TSInterfaceDeclaration = 'TSInterfaceDeclaration',
TSInterfaceHeritage = 'TSInterfaceHeritage',
TSIntersectionType = 'TSIntersectionType',
TSIntrinsicKeyword = 'TSIntrinsicKeyword',
TSLiteralType = 'TSLiteralType',
TSMappedType = 'TSMappedType',
TSMethodSignature = 'TSMethodSignature',
TSModuleBlock = 'TSModuleBlock',
TSModuleDeclaration = 'TSModuleDeclaration',
TSNamedTupleMember = 'TSNamedTupleMember',
TSNamespaceExportDeclaration = 'TSNamespaceExportDeclaration',
TSNeverKeyword = 'TSNeverKeyword',
TSNonNullExpression = 'TSNonNullExpression',
TSNullKeyword = 'TSNullKeyword',
TSNumberKeyword = 'TSNumberKeyword',
TSObjectKeyword = 'TSObjectKeyword',
TSOptionalType = 'TSOptionalType',
TSParameterProperty = 'TSParameterProperty',
TSPrivateKeyword = 'TSPrivateKeyword',
TSPropertySignature = 'TSPropertySignature',
TSProtectedKeyword = 'TSProtectedKeyword',
TSPublicKeyword = 'TSPublicKeyword',
TSQualifiedName = 'TSQualifiedName',
TSReadonlyKeyword = 'TSReadonlyKeyword',
TSRestType = 'TSRestType',
TSSatisfiesExpression = 'TSSatisfiesExpression',
TSStaticKeyword = 'TSStaticKeyword',
TSStringKeyword = 'TSStringKeyword',
TSSymbolKeyword = 'TSSymbolKeyword',
TSTemplateLiteralType = 'TSTemplateLiteralType',
TSThisType = 'TSThisType',
TSTupleType = 'TSTupleType',
TSTypeAliasDeclaration = 'TSTypeAliasDeclaration',
TSTypeAnnotation = 'TSTypeAnnotation',
TSTypeAssertion = 'TSTypeAssertion',
TSTypeLiteral = 'TSTypeLiteral',
TSTypeOperator = 'TSTypeOperator',
TSTypeParameter = 'TSTypeParameter',
TSTypeParameterDeclaration = 'TSTypeParameterDeclaration',
TSTypeParameterInstantiation = 'TSTypeParameterInstantiation',
TSTypePredicate = 'TSTypePredicate',
TSTypeQuery = 'TSTypeQuery',
TSTypeReference = 'TSTypeReference',
TSUndefinedKeyword = 'TSUndefinedKeyword',
TSUnionType = 'TSUnionType',
TSUnknownKeyword = 'TSUnknownKeyword',
TSVoidKeyword = 'TSVoidKeyword',
}Usage Examples:
import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/types";
// Type-safe node identification
function processNode(node: TSESTree.Node): void {
switch (node.type) {
case AST_NODE_TYPES.FunctionDeclaration:
// TypeScript knows this is a FunctionDeclaration
console.log(`Function name: ${node.id?.name}`);
break;
case AST_NODE_TYPES.VariableDeclaration:
// TypeScript knows this is a VariableDeclaration
node.declarations.forEach(declarator => {
if (declarator.id.type === AST_NODE_TYPES.Identifier) {
console.log(`Variable: ${declarator.id.name}`);
}
});
break;
case AST_NODE_TYPES.TSInterfaceDeclaration:
// TypeScript-specific node handling
console.log(`Interface: ${node.id.name}`);
break;
}
}
// Check for TypeScript-specific nodes
function isTypeScriptNode(nodeType: AST_NODE_TYPES): boolean {
return nodeType.startsWith('TS');
}
// Group nodes by category
const STATEMENT_NODES = [
AST_NODE_TYPES.BlockStatement,
AST_NODE_TYPES.BreakStatement,
AST_NODE_TYPES.ContinueStatement,
AST_NODE_TYPES.DoWhileStatement,
AST_NODE_TYPES.ExpressionStatement,
AST_NODE_TYPES.ForStatement,
AST_NODE_TYPES.IfStatement,
AST_NODE_TYPES.ReturnStatement,
AST_NODE_TYPES.WhileStatement,
] as const;The AST node types can be organized into several logical categories:
FunctionDeclaration, VariableDeclaration, ClassDeclarationIfStatement, ForStatement, WhileStatement, BlockStatementBinaryExpression, CallExpression, MemberExpressionLiteral, TemplateLiteralIdentifier, PrivateIdentifierClassBody, MethodDefinition, PropertyDefinition, StaticBlockImportDeclaration, ExportDeclaration, ImportSpecifierAwaitExpression, ArrowFunctionExpressionArrayPattern, ObjectPattern, RestElementJSXElement, JSXFragment, JSXTextJSXAttribute, JSXSpreadAttributeJSXIdentifier, JSXMemberExpressionTSTypeAnnotation, TSAsExpression, TSTypeAssertionTSInterfaceDeclaration, TSTypeAliasDeclaration, TSEnumDeclarationTSUnionType, TSIntersectionType, TSMappedTypeTSPublicKeyword, TSPrivateKeyword, TSReadonlyKeywordInstall with Tessl CLI
npx tessl i tessl/npm-typescript-eslint--types