Skip to content

Commit f914e49

Browse files
committed
feat(interfaces): expand AST node type definitions 🌳
- Add ArrayPattern interface for array destructuring patterns - Add BigIntLiteral interface for BigInt literal expressions - Add ClassField interface for class field declarations - Add ClassMethod interface for class method definitions - Add DebuggerStatement interface for debugger statements - Add DoWhileStatement interface for do-while loop statements - Add EmptyStatement interface for empty statements - Add ExportAllDeclaration interface for export all declarations - Add ExportDefaultDeclaration interface for default exports - Add ForInStatement interface for for-in loop statements - Add Hashbang interface for hashbang directives - Add ImportAssertion interface for import assertions - Add ImportAttribute interface for import attributes - Add ImportDeclaration interface for import declarations - Add ImportDefaultSpecifier interface for default import specifiers - Add ImportExpression interface for dynamic import expressions - Add ImportNamespaceSpecifier interface for namespace import specifiers - Add ImportSpecifier interface for named import specifiers - Add LabeledStatement interface for labeled statements - Add LogicalAssignment interface for logical assignment operators - Add MetaProperty interface for meta properties - Add NullishCoalescing interface for nullish coalescing operators - Add NumericSeparator interface for numeric separators - Add OptionalChaining interface for optional chaining operators - Add PipelineOperator interface for pipeline operators - Add PrivateIdentifier interface for private identifiers - Add RegExpLiteral interface for regular expression literals - Add RegExpWithIndices interface for regex with indices - Add SequenceExpression interface for sequence expressions - Add StaticBlock interface for static blocks - Add Super interface for super expressions - Add TopLevelAwait interface for top-level await - Add WithStatement interface for with statements - Update DenoContext with AST node type definitions - Update existing interfaces to include new node type references - Update ValidatorUtils with minor interface adjustments
1 parent fbdff58 commit f914e49

44 files changed

Lines changed: 617 additions & 15 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/interfaces/ArrayPattern.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { ASTNode } from '@interfaces/index.ts'
2+
3+
/**
4+
* AST node representing an array pattern.
5+
*/
6+
export interface ArrayPatternNode {
7+
/** Type identifier for array patterns */
8+
type: 'ArrayPattern'
9+
/** Source code range */
10+
range: [number, number]
11+
/** Pattern elements */
12+
elements: Array<ASTNode | null>
13+
}

src/interfaces/AwaitExpression.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type { ASTNode } from '@interfaces/index.ts'
66
export interface AwaitExpressionNode {
77
/** Type identifier for await expressions */
88
type: 'AwaitExpression'
9+
/** Source code range */
10+
range: [number, number]
911
/** Expression being awaited */
1012
argument: ASTNode
1113
}

src/interfaces/BigIntLiteral.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* AST node representing a BigInt literal.
3+
*/
4+
export interface BigIntLiteralNode {
5+
/** Type identifier for BigInt literals */
6+
type: 'BigIntLiteral'
7+
/** Source code range */
8+
range: [number, number]
9+
/** BigInt value */
10+
value?: bigint | null
11+
/** BigInt string */
12+
bigint: string
13+
/** Raw string representation */
14+
raw?: string
15+
}

src/interfaces/CallExpression.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ import type { ASTNode } from '@interfaces/index.ts'
66
export interface CallExpressionNode {
77
/** Type identifier for call expressions */
88
type: 'CallExpression'
9+
/** Source code range */
10+
range: [number, number]
11+
/** Whether this is an optional call */
12+
optional: boolean
913
/** The function being called */
1014
callee: ASTNode
15+
/** Type arguments for generic calls */
16+
typeArguments?: ASTNode | null
1117
/** Array of arguments passed to the function */
1218
arguments: Array<ASTNode>
1319
/** Optional parent node reference */

src/interfaces/ChainExpression.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import type { ASTNode } from '@interfaces/index.ts'
22

33
/**
4-
* AST node representing optional chaining expression.
4+
* AST node representing a chain expression (optional chaining).
55
*/
66
export interface ChainExpressionNode {
77
/** Type identifier for chain expressions */
88
type: 'ChainExpression'
9-
/** The chained expression */
9+
/** Source code range */
10+
range: [number, number]
11+
/** Chain element */
1012
expression: ASTNode
1113
}

src/interfaces/ClassField.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { ASTNode } from '@interfaces/index.ts'
2+
3+
/**
4+
* AST node representing a class field with initialization.
5+
*/
6+
export interface ClassFieldNode {
7+
/** Type identifier for class fields */
8+
type: 'ClassField'
9+
/** Source code range */
10+
range: [number, number]
11+
/** Field key */
12+
key: ASTNode
13+
/** Field value */
14+
value?: ASTNode
15+
/** Whether the field is static */
16+
static: boolean
17+
/** Whether the field is private */
18+
private: boolean
19+
/** Whether the field is readonly */
20+
readonly: boolean
21+
/** Field decorators */
22+
decorators?: ASTNode[]
23+
}

src/interfaces/ClassMethod.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { ASTNode } from '@interfaces/index.ts'
2+
3+
/**
4+
* AST node representing a class method with modern syntax.
5+
*/
6+
export interface ClassMethodNode {
7+
/** Type identifier for class methods */
8+
type: 'ClassMethod'
9+
/** Source code range */
10+
range: [number, number]
11+
/** Method key */
12+
key: ASTNode
13+
/** Method parameters */
14+
params: ASTNode[]
15+
/** Method body */
16+
body: ASTNode
17+
/** Whether the method is static */
18+
static: boolean
19+
/** Whether the method is private */
20+
private: boolean
21+
/** Whether the method is async */
22+
async: boolean
23+
/** Whether the method is generator */
24+
generator: boolean
25+
/** Method decorators */
26+
decorators?: ASTNode[]
27+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* AST node representing a debugger statement.
3+
*/
4+
export interface DebuggerStatementNode {
5+
/** Type identifier for debugger statements */
6+
type: 'DebuggerStatement'
7+
/** Source code range */
8+
range: [number, number]
9+
}

src/interfaces/DenoContext.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
AssignmentExpressionNode,
55
AssignmentPatternNode,
66
AwaitExpressionNode,
7+
BigIntLiteralNode,
78
BinaryExpressionNode,
89
BlockStatementNode,
910
BreakStatementNode,
@@ -13,37 +14,67 @@ import type {
1314
ClassBodyNode,
1415
ClassDeclarationNode,
1516
ClassExpressionNode,
17+
ClassFieldNode,
18+
ClassMethodNode,
1619
ConditionalExpressionNode,
20+
DebuggerStatementNode,
1721
DecoratorNode,
22+
DoWhileStatementNode,
23+
EmptyStatementNode,
24+
ExportAllDeclarationNode,
25+
ExportDefaultDeclarationNode,
1826
ExportNamedDeclarationNode,
1927
ExportSpecifierNode,
2028
ExpressionStatementNode,
29+
ForInStatementNode,
2130
ForOfStatementNode,
2231
ForStatementNode,
2332
FunctionDeclarationNode,
2433
FunctionExpressionNode,
34+
HashbangNode,
2535
IdentifierNode,
2636
IfStatementNode,
37+
ImportAssertionNode,
38+
ImportAttributeNode,
39+
ImportDeclarationNode,
40+
ImportDefaultSpecifierNode,
41+
ImportExpressionNode,
42+
ImportNamespaceSpecifierNode,
43+
ImportSpecifierNode,
44+
LabeledStatementNode,
2745
LiteralNode,
46+
LogicalAssignmentNode,
2847
LogicalExpressionNode,
2948
MemberExpressionNode,
49+
MetaPropertyNode,
3050
MethodDefinitionNode,
3151
NewExpressionNode,
52+
NullishCoalescingNode,
53+
NumericSeparatorNode,
3254
ObjectExpressionNode,
3355
ObjectPatternNode,
56+
OptionalChainingNode,
3457
ParameterNode,
58+
PipelineOperatorNode,
59+
PrivateIdentifierNode,
3560
ProgramNode,
3661
PropertyDefinitionNode,
3762
PropertyNode,
63+
RegExpLiteralNode,
64+
RegExpWithIndicesNode,
3865
RestElementNode,
3966
ReturnStatementNode,
67+
SequenceExpressionNode,
4068
SpreadElementNode,
69+
StaticBlockNode,
70+
SuperNode,
4171
SwitchCaseNode,
4272
SwitchStatementNode,
4373
TemplateElementNode,
4474
TemplateLiteralNode,
4575
ThisExpressionNode,
4676
ThrowStatementNode,
77+
TopLevelAwaitNode,
4778
TryStatementNode,
4879
TSAnyKeywordNode,
4980
TSArrayTypeNode,
@@ -56,6 +87,7 @@ import type {
5687
TSEnumBodyNode,
5788
TSEnumDeclarationNode,
5889
TSEnumMemberNode,
90+
TSExpressionWithTypeArgumentsNode,
5991
TSFunctionTypeNode,
6092
TSIndexedAccessTypeNode,
6193
TSIndexSignatureNode,
@@ -103,6 +135,7 @@ import type {
103135
VariableDeclarationNode,
104136
VariableDeclaratorNode,
105137
WhileStatementNode,
138+
WithStatementNode,
106139
YieldExpressionNode
107140
} from '@interfaces/index.ts'
108141

@@ -115,6 +148,7 @@ export type JSASTNode =
115148
| AssignmentExpressionNode
116149
| AssignmentPatternNode
117150
| AwaitExpressionNode
151+
| BigIntLiteralNode
118152
| BinaryExpressionNode
119153
| BlockStatementNode
120154
| BreakStatementNode
@@ -124,43 +158,74 @@ export type JSASTNode =
124158
| ClassBodyNode
125159
| ClassDeclarationNode
126160
| ClassExpressionNode
161+
| ClassFieldNode
162+
| ClassMethodNode
127163
| ConditionalExpressionNode
164+
| DebuggerStatementNode
128165
| DecoratorNode
166+
| DoWhileStatementNode
167+
| EmptyStatementNode
168+
| ExportAllDeclarationNode
169+
| ExportDefaultDeclarationNode
129170
| ExportNamedDeclarationNode
130171
| ExportSpecifierNode
131172
| ExpressionStatementNode
173+
| ForInStatementNode
132174
| ForOfStatementNode
133175
| ForStatementNode
134176
| FunctionDeclarationNode
135177
| FunctionExpressionNode
178+
| HashbangNode
136179
| IdentifierNode
137180
| IfStatementNode
181+
| ImportAssertionNode
182+
| ImportAttributeNode
183+
| ImportDeclarationNode
184+
| ImportDefaultSpecifierNode
185+
| ImportExpressionNode
186+
| ImportNamespaceSpecifierNode
187+
| ImportSpecifierNode
188+
| LabeledStatementNode
138189
| LiteralNode
190+
| LogicalAssignmentNode
139191
| LogicalExpressionNode
140192
| MemberExpressionNode
193+
| MetaPropertyNode
141194
| MethodDefinitionNode
142195
| NewExpressionNode
196+
| NullishCoalescingNode
197+
| NumericSeparatorNode
143198
| ObjectExpressionNode
144199
| ObjectPatternNode
200+
| OptionalChainingNode
145201
| ParameterNode
202+
| PipelineOperatorNode
203+
| PrivateIdentifierNode
146204
| ProgramNode
147205
| PropertyNode
148206
| PropertyDefinitionNode
207+
| RegExpLiteralNode
208+
| RegExpWithIndicesNode
149209
| RestElementNode
150210
| ReturnStatementNode
211+
| SequenceExpressionNode
151212
| SpreadElementNode
213+
| StaticBlockNode
214+
| SuperNode
152215
| SwitchCaseNode
153216
| SwitchStatementNode
154217
| TemplateElementNode
155218
| TemplateLiteralNode
156219
| ThisExpressionNode
157220
| ThrowStatementNode
221+
| TopLevelAwaitNode
158222
| TryStatementNode
159223
| UnaryExpressionNode
160224
| UpdateExpressionNode
161225
| VariableDeclarationNode
162226
| VariableDeclaratorNode
163227
| WhileStatementNode
228+
| WithStatementNode
164229
| YieldExpressionNode
165230

166231
/**
@@ -178,6 +243,7 @@ export type TSASTNode =
178243
| TSEnumBodyNode
179244
| TSEnumDeclarationNode
180245
| TSEnumMemberNode
246+
| TSExpressionWithTypeArgumentsNode
181247
| TSFunctionTypeNode
182248
| TSIndexedAccessTypeNode
183249
| TSIndexSignatureNode

src/interfaces/DoWhileStatement.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { ASTNode } from '@interfaces/index.ts'
2+
3+
/**
4+
* AST node representing a do-while statement.
5+
*/
6+
export interface DoWhileStatementNode {
7+
/** Type identifier for do-while statements */
8+
type: 'DoWhileStatement'
9+
/** Source code range */
10+
range: [number, number]
11+
/** Loop body */
12+
body: ASTNode
13+
/** Loop test condition */
14+
test: ASTNode
15+
}

0 commit comments

Comments
 (0)