Skip to content

Commit 2466014

Browse files
committed
Expose visitorKeys
1 parent c79ced6 commit 2466014

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './estree-parser.js';
22
export type { NGMicrosyntax, NGNode } from './types.ts';
3+
export { visitorKeys } from './visitor-keys.js';

src/types.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export interface NGBaseNode extends LocationInformation {
1111
type: string;
1212
}
1313

14-
export type NGNode =
15-
| babel.Node
14+
export type NGOwnNode =
1615
| NGMicrosyntaxNode
1716
| NGEmptyExpression
1817
| NGPipeExpression
19-
| NGQuotedExpression
2018
| NGChainedExpression;
2119

20+
export type NGNode = babel.Node | NGOwnNode;
21+
2222
export type CommentLine = babel.CommentLine & LocationInformation;
2323

2424
export interface NGEmptyExpression extends NGBaseNode {
@@ -32,12 +32,6 @@ export interface NGPipeExpression extends NGBaseNode {
3232
arguments: babel.Expression[];
3333
}
3434

35-
export interface NGQuotedExpression extends NGBaseNode {
36-
type: 'NGQuotedExpression';
37-
prefix: string;
38-
value: string;
39-
}
40-
4135
export interface NGChainedExpression extends NGBaseNode {
4236
type: 'NGChainedExpression';
4337
expressions: NGNode[];

src/visitor-keys.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { NGOwnNode } from './types.ts';
2+
3+
type VisitorKeys = {
4+
[P in NGOwnNode as P['type']]: (keyof P)[];
5+
};
6+
7+
export const visitorKeys: VisitorKeys = {
8+
NGChainedExpression: ['expressions'],
9+
NGEmptyExpression: [],
10+
NGPipeExpression: ['left', 'right', 'arguments'],
11+
NGMicrosyntax: ['body'],
12+
NGMicrosyntaxAs: ['key', 'alias'],
13+
NGMicrosyntaxExpression: ['expression', 'alias'],
14+
NGMicrosyntaxKey: [],
15+
NGMicrosyntaxKeyedExpression: ['key', 'expression'],
16+
NGMicrosyntaxLet: ['key', 'value'],
17+
};

0 commit comments

Comments
 (0)