Node interface and are classified by their SyntaxKind.
Base Node Interface
All AST nodes extend theNode interface:
Key Properties
| Property | Type | Description |
|---|---|---|
kind | SyntaxKind | The syntax kind identifying the node type |
flags | NodeFlags | Bitwise flags for node properties |
parent | Node | Parent node in the AST |
pos | number | Start position in source text |
end | number | End position in source text |
Core Node Types
Declaration Nodes
VariableDeclaration- Variable declarationsFunctionDeclaration- Function declarationsClassDeclaration- Class declarationsInterfaceDeclaration- Interface declarationsTypeAliasDeclaration- Type alias declarationsEnumDeclaration- Enum declarationsParameterDeclaration- Parameter declarations
Expression Nodes
Expressions are nodes that can be evaluated to produce a value:| Type | Description |
|---|---|
Identifier | Variable or property name |
BinaryExpression | Binary operations (e.g., a + b) |
CallExpression | Function calls |
PropertyAccessExpression | Property access (e.g., obj.prop) |
ElementAccessExpression | Bracket notation (e.g., arr[0]) |
ArrowFunction | Arrow function expressions |
FunctionExpression | Function expressions |
Statement Nodes
Statements are executable units of code:Type Nodes
Type nodes represent TypeScript type annotations:Container Nodes
Some nodes act as containers for other declarations:LocalsContainer
Nodes that can contain local symbols:SourceFileFunctionDeclarationModuleDeclarationBlockForStatementCatchClause
FlowContainer
Nodes with control flow analysis:- Functions and methods
- Statements (if, while, for, etc.)
- Expressions with side effects
Common Node Patterns
Signature Declarations
FunctionDeclarationMethodDeclarationConstructorDeclarationCallSignatureDeclarationConstructSignatureDeclaration
Variable Declarations
Parameter Declarations
Working with Nodes
Type Guards
Use type guards to narrow node types:Traversing the AST
Node Relationships
Parent-Child
Every node (except the root) has a parent:Source File
Get the source file for any node:See Also
- SyntaxKind - Complete list of syntax kinds
- TypeFlags - Type system flags
- SymbolFlags - Symbol classification flags