oxc-parser 0.99.0 → 0.102.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,187 +4,187 @@
4
4
  // Mapping from node type name to node type ID
5
5
  export const NODE_TYPE_IDS_MAP = new Map([
6
6
  // Leaf nodes
7
- ['IdentifierName', 0],
8
- ['IdentifierReference', 1],
9
- ['BindingIdentifier', 2],
10
- ['LabelIdentifier', 3],
11
- ['ThisExpression', 4],
12
- ['Elision', 5],
13
- ['TemplateElement', 6],
14
- ['Super', 7],
15
- ['Hashbang', 8],
16
- ['EmptyStatement', 9],
17
- ['DebuggerStatement', 10],
18
- ['PrivateIdentifier', 11],
19
- ['BooleanLiteral', 12],
20
- ['NullLiteral', 13],
21
- ['NumericLiteral', 14],
22
- ['StringLiteral', 15],
23
- ['BigIntLiteral', 16],
24
- ['RegExpLiteral', 17],
25
- ['JSXOpeningFragment', 18],
26
- ['JSXClosingFragment', 19],
27
- ['JSXEmptyExpression', 20],
28
- ['JSXIdentifier', 21],
29
- ['JSXText', 22],
30
- ['TSAnyKeyword', 23],
31
- ['TSStringKeyword', 24],
32
- ['TSBooleanKeyword', 25],
33
- ['TSNumberKeyword', 26],
34
- ['TSNeverKeyword', 27],
35
- ['TSIntrinsicKeyword', 28],
36
- ['TSUnknownKeyword', 29],
37
- ['TSNullKeyword', 30],
38
- ['TSUndefinedKeyword', 31],
39
- ['TSVoidKeyword', 32],
40
- ['TSSymbolKeyword', 33],
41
- ['TSThisType', 34],
42
- ['TSObjectKeyword', 35],
43
- ['TSBigIntKeyword', 36],
44
- ['JSDocUnknownType', 37],
7
+ ["IdentifierName", 0],
8
+ ["IdentifierReference", 1],
9
+ ["BindingIdentifier", 2],
10
+ ["LabelIdentifier", 3],
11
+ ["ThisExpression", 4],
12
+ ["Elision", 5],
13
+ ["TemplateElement", 6],
14
+ ["Super", 7],
15
+ ["Hashbang", 8],
16
+ ["EmptyStatement", 9],
17
+ ["DebuggerStatement", 10],
18
+ ["PrivateIdentifier", 11],
19
+ ["BooleanLiteral", 12],
20
+ ["NullLiteral", 13],
21
+ ["NumericLiteral", 14],
22
+ ["StringLiteral", 15],
23
+ ["BigIntLiteral", 16],
24
+ ["RegExpLiteral", 17],
25
+ ["JSXOpeningFragment", 18],
26
+ ["JSXClosingFragment", 19],
27
+ ["JSXEmptyExpression", 20],
28
+ ["JSXIdentifier", 21],
29
+ ["JSXText", 22],
30
+ ["TSAnyKeyword", 23],
31
+ ["TSStringKeyword", 24],
32
+ ["TSBooleanKeyword", 25],
33
+ ["TSNumberKeyword", 26],
34
+ ["TSNeverKeyword", 27],
35
+ ["TSIntrinsicKeyword", 28],
36
+ ["TSUnknownKeyword", 29],
37
+ ["TSNullKeyword", 30],
38
+ ["TSUndefinedKeyword", 31],
39
+ ["TSVoidKeyword", 32],
40
+ ["TSSymbolKeyword", 33],
41
+ ["TSThisType", 34],
42
+ ["TSObjectKeyword", 35],
43
+ ["TSBigIntKeyword", 36],
44
+ ["JSDocUnknownType", 37],
45
45
  // Non-leaf nodes
46
- ['Program', 38],
47
- ['ArrayExpression', 39],
48
- ['ObjectExpression', 40],
49
- ['ObjectProperty', 41],
50
- ['TemplateLiteral', 42],
51
- ['TaggedTemplateExpression', 43],
52
- ['ComputedMemberExpression', 44],
53
- ['StaticMemberExpression', 45],
54
- ['PrivateFieldExpression', 46],
55
- ['CallExpression', 47],
56
- ['NewExpression', 48],
57
- ['MetaProperty', 49],
58
- ['SpreadElement', 50],
59
- ['UpdateExpression', 51],
60
- ['UnaryExpression', 52],
61
- ['BinaryExpression', 53],
62
- ['PrivateInExpression', 54],
63
- ['LogicalExpression', 55],
64
- ['ConditionalExpression', 56],
65
- ['AssignmentExpression', 57],
66
- ['ArrayAssignmentTarget', 58],
67
- ['ObjectAssignmentTarget', 59],
68
- ['AssignmentTargetWithDefault', 60],
69
- ['AssignmentTargetPropertyIdentifier', 61],
70
- ['AssignmentTargetPropertyProperty', 62],
71
- ['SequenceExpression', 63],
72
- ['AwaitExpression', 64],
73
- ['ChainExpression', 65],
74
- ['ParenthesizedExpression', 66],
75
- ['BlockStatement', 67],
76
- ['VariableDeclaration', 68],
77
- ['VariableDeclarator', 69],
78
- ['ExpressionStatement', 70],
79
- ['IfStatement', 71],
80
- ['DoWhileStatement', 72],
81
- ['WhileStatement', 73],
82
- ['ForStatement', 74],
83
- ['ForInStatement', 75],
84
- ['ForOfStatement', 76],
85
- ['ContinueStatement', 77],
86
- ['BreakStatement', 78],
87
- ['ReturnStatement', 79],
88
- ['WithStatement', 80],
89
- ['SwitchStatement', 81],
90
- ['SwitchCase', 82],
91
- ['LabeledStatement', 83],
92
- ['ThrowStatement', 84],
93
- ['TryStatement', 85],
94
- ['CatchClause', 86],
95
- ['AssignmentPattern', 87],
96
- ['ObjectPattern', 88],
97
- ['BindingProperty', 89],
98
- ['ArrayPattern', 90],
99
- ['Function', 91],
100
- ['FormalParameters', 92],
101
- ['FunctionBody', 93],
102
- ['ArrowFunctionExpression', 94],
103
- ['YieldExpression', 95],
104
- ['Class', 96],
105
- ['ClassBody', 97],
106
- ['MethodDefinition', 98],
107
- ['PropertyDefinition', 99],
108
- ['StaticBlock', 100],
109
- ['AccessorProperty', 101],
110
- ['ImportExpression', 102],
111
- ['ImportDeclaration', 103],
112
- ['ImportSpecifier', 104],
113
- ['ImportDefaultSpecifier', 105],
114
- ['ImportNamespaceSpecifier', 106],
115
- ['ImportAttribute', 107],
116
- ['ExportNamedDeclaration', 108],
117
- ['ExportDefaultDeclaration', 109],
118
- ['ExportAllDeclaration', 110],
119
- ['ExportSpecifier', 111],
120
- ['V8IntrinsicExpression', 112],
121
- ['JSXElement', 113],
122
- ['JSXOpeningElement', 114],
123
- ['JSXClosingElement', 115],
124
- ['JSXFragment', 116],
125
- ['JSXNamespacedName', 117],
126
- ['JSXMemberExpression', 118],
127
- ['JSXExpressionContainer', 119],
128
- ['JSXAttribute', 120],
129
- ['JSXSpreadAttribute', 121],
130
- ['JSXSpreadChild', 122],
131
- ['TSEnumDeclaration', 123],
132
- ['TSEnumBody', 124],
133
- ['TSEnumMember', 125],
134
- ['TSTypeAnnotation', 126],
135
- ['TSLiteralType', 127],
136
- ['TSConditionalType', 128],
137
- ['TSUnionType', 129],
138
- ['TSIntersectionType', 130],
139
- ['TSParenthesizedType', 131],
140
- ['TSTypeOperator', 132],
141
- ['TSArrayType', 133],
142
- ['TSIndexedAccessType', 134],
143
- ['TSTupleType', 135],
144
- ['TSNamedTupleMember', 136],
145
- ['TSOptionalType', 137],
146
- ['TSRestType', 138],
147
- ['TSTypeReference', 139],
148
- ['TSQualifiedName', 140],
149
- ['TSTypeParameterInstantiation', 141],
150
- ['TSTypeParameter', 142],
151
- ['TSTypeParameterDeclaration', 143],
152
- ['TSTypeAliasDeclaration', 144],
153
- ['TSClassImplements', 145],
154
- ['TSInterfaceDeclaration', 146],
155
- ['TSInterfaceBody', 147],
156
- ['TSPropertySignature', 148],
157
- ['TSIndexSignature', 149],
158
- ['TSCallSignatureDeclaration', 150],
159
- ['TSMethodSignature', 151],
160
- ['TSConstructSignatureDeclaration', 152],
161
- ['TSIndexSignatureName', 153],
162
- ['TSInterfaceHeritage', 154],
163
- ['TSTypePredicate', 155],
164
- ['TSModuleDeclaration', 156],
165
- ['TSGlobalDeclaration', 157],
166
- ['TSModuleBlock', 158],
167
- ['TSTypeLiteral', 159],
168
- ['TSInferType', 160],
169
- ['TSTypeQuery', 161],
170
- ['TSImportType', 162],
171
- ['TSImportTypeQualifiedName', 163],
172
- ['TSFunctionType', 164],
173
- ['TSConstructorType', 165],
174
- ['TSMappedType', 166],
175
- ['TSTemplateLiteralType', 167],
176
- ['TSAsExpression', 168],
177
- ['TSSatisfiesExpression', 169],
178
- ['TSTypeAssertion', 170],
179
- ['TSImportEqualsDeclaration', 171],
180
- ['TSExternalModuleReference', 172],
181
- ['TSNonNullExpression', 173],
182
- ['Decorator', 174],
183
- ['TSExportAssignment', 175],
184
- ['TSNamespaceExportDeclaration', 176],
185
- ['TSInstantiationExpression', 177],
186
- ['JSDocNullableType', 178],
187
- ['JSDocNonNullableType', 179],
46
+ ["Program", 38],
47
+ ["ArrayExpression", 39],
48
+ ["ObjectExpression", 40],
49
+ ["ObjectProperty", 41],
50
+ ["TemplateLiteral", 42],
51
+ ["TaggedTemplateExpression", 43],
52
+ ["ComputedMemberExpression", 44],
53
+ ["StaticMemberExpression", 45],
54
+ ["PrivateFieldExpression", 46],
55
+ ["CallExpression", 47],
56
+ ["NewExpression", 48],
57
+ ["MetaProperty", 49],
58
+ ["SpreadElement", 50],
59
+ ["UpdateExpression", 51],
60
+ ["UnaryExpression", 52],
61
+ ["BinaryExpression", 53],
62
+ ["PrivateInExpression", 54],
63
+ ["LogicalExpression", 55],
64
+ ["ConditionalExpression", 56],
65
+ ["AssignmentExpression", 57],
66
+ ["ArrayAssignmentTarget", 58],
67
+ ["ObjectAssignmentTarget", 59],
68
+ ["AssignmentTargetWithDefault", 60],
69
+ ["AssignmentTargetPropertyIdentifier", 61],
70
+ ["AssignmentTargetPropertyProperty", 62],
71
+ ["SequenceExpression", 63],
72
+ ["AwaitExpression", 64],
73
+ ["ChainExpression", 65],
74
+ ["ParenthesizedExpression", 66],
75
+ ["BlockStatement", 67],
76
+ ["VariableDeclaration", 68],
77
+ ["VariableDeclarator", 69],
78
+ ["ExpressionStatement", 70],
79
+ ["IfStatement", 71],
80
+ ["DoWhileStatement", 72],
81
+ ["WhileStatement", 73],
82
+ ["ForStatement", 74],
83
+ ["ForInStatement", 75],
84
+ ["ForOfStatement", 76],
85
+ ["ContinueStatement", 77],
86
+ ["BreakStatement", 78],
87
+ ["ReturnStatement", 79],
88
+ ["WithStatement", 80],
89
+ ["SwitchStatement", 81],
90
+ ["SwitchCase", 82],
91
+ ["LabeledStatement", 83],
92
+ ["ThrowStatement", 84],
93
+ ["TryStatement", 85],
94
+ ["CatchClause", 86],
95
+ ["AssignmentPattern", 87],
96
+ ["ObjectPattern", 88],
97
+ ["BindingProperty", 89],
98
+ ["ArrayPattern", 90],
99
+ ["Function", 91],
100
+ ["FormalParameters", 92],
101
+ ["FunctionBody", 93],
102
+ ["ArrowFunctionExpression", 94],
103
+ ["YieldExpression", 95],
104
+ ["Class", 96],
105
+ ["ClassBody", 97],
106
+ ["MethodDefinition", 98],
107
+ ["PropertyDefinition", 99],
108
+ ["StaticBlock", 100],
109
+ ["AccessorProperty", 101],
110
+ ["ImportExpression", 102],
111
+ ["ImportDeclaration", 103],
112
+ ["ImportSpecifier", 104],
113
+ ["ImportDefaultSpecifier", 105],
114
+ ["ImportNamespaceSpecifier", 106],
115
+ ["ImportAttribute", 107],
116
+ ["ExportNamedDeclaration", 108],
117
+ ["ExportDefaultDeclaration", 109],
118
+ ["ExportAllDeclaration", 110],
119
+ ["ExportSpecifier", 111],
120
+ ["V8IntrinsicExpression", 112],
121
+ ["JSXElement", 113],
122
+ ["JSXOpeningElement", 114],
123
+ ["JSXClosingElement", 115],
124
+ ["JSXFragment", 116],
125
+ ["JSXNamespacedName", 117],
126
+ ["JSXMemberExpression", 118],
127
+ ["JSXExpressionContainer", 119],
128
+ ["JSXAttribute", 120],
129
+ ["JSXSpreadAttribute", 121],
130
+ ["JSXSpreadChild", 122],
131
+ ["TSEnumDeclaration", 123],
132
+ ["TSEnumBody", 124],
133
+ ["TSEnumMember", 125],
134
+ ["TSTypeAnnotation", 126],
135
+ ["TSLiteralType", 127],
136
+ ["TSConditionalType", 128],
137
+ ["TSUnionType", 129],
138
+ ["TSIntersectionType", 130],
139
+ ["TSParenthesizedType", 131],
140
+ ["TSTypeOperator", 132],
141
+ ["TSArrayType", 133],
142
+ ["TSIndexedAccessType", 134],
143
+ ["TSTupleType", 135],
144
+ ["TSNamedTupleMember", 136],
145
+ ["TSOptionalType", 137],
146
+ ["TSRestType", 138],
147
+ ["TSTypeReference", 139],
148
+ ["TSQualifiedName", 140],
149
+ ["TSTypeParameterInstantiation", 141],
150
+ ["TSTypeParameter", 142],
151
+ ["TSTypeParameterDeclaration", 143],
152
+ ["TSTypeAliasDeclaration", 144],
153
+ ["TSClassImplements", 145],
154
+ ["TSInterfaceDeclaration", 146],
155
+ ["TSInterfaceBody", 147],
156
+ ["TSPropertySignature", 148],
157
+ ["TSIndexSignature", 149],
158
+ ["TSCallSignatureDeclaration", 150],
159
+ ["TSMethodSignature", 151],
160
+ ["TSConstructSignatureDeclaration", 152],
161
+ ["TSIndexSignatureName", 153],
162
+ ["TSInterfaceHeritage", 154],
163
+ ["TSTypePredicate", 155],
164
+ ["TSModuleDeclaration", 156],
165
+ ["TSGlobalDeclaration", 157],
166
+ ["TSModuleBlock", 158],
167
+ ["TSTypeLiteral", 159],
168
+ ["TSInferType", 160],
169
+ ["TSTypeQuery", 161],
170
+ ["TSImportType", 162],
171
+ ["TSImportTypeQualifiedName", 163],
172
+ ["TSFunctionType", 164],
173
+ ["TSConstructorType", 165],
174
+ ["TSMappedType", 166],
175
+ ["TSTemplateLiteralType", 167],
176
+ ["TSAsExpression", 168],
177
+ ["TSSatisfiesExpression", 169],
178
+ ["TSTypeAssertion", 170],
179
+ ["TSImportEqualsDeclaration", 171],
180
+ ["TSExternalModuleReference", 172],
181
+ ["TSNonNullExpression", 173],
182
+ ["Decorator", 174],
183
+ ["TSExportAssignment", 175],
184
+ ["TSNamespaceExportDeclaration", 176],
185
+ ["TSInstantiationExpression", 177],
186
+ ["JSDocNullableType", 178],
187
+ ["JSDocNonNullableType", 179],
188
188
  ]);
189
189
 
190
190
  export const NODE_TYPES_COUNT = 180;
@@ -182,7 +182,7 @@ import {
182
182
  JSDocNullableType,
183
183
  JSDocNonNullableType,
184
184
  JSDocUnknownType,
185
- } from './constructors.js';
185
+ } from "./constructors.js";
186
186
 
187
187
  export { walkProgram };
188
188
 
@@ -1268,7 +1268,9 @@ function walkAssignmentTargetMaybeDefault(pos, ast, visitors) {
1268
1268
  walkBoxPrivateFieldExpression(pos + 8, ast, visitors);
1269
1269
  return;
1270
1270
  default:
1271
- throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for AssignmentTargetMaybeDefault`);
1271
+ throw new Error(
1272
+ `Unexpected discriminant ${ast.buffer[pos]} for AssignmentTargetMaybeDefault`,
1273
+ );
1272
1274
  }
1273
1275
  }
1274
1276
 
@@ -2768,7 +2770,9 @@ function walkExportDefaultDeclarationKind(pos, ast, visitors) {
2768
2770
  walkBoxTSInterfaceDeclaration(pos + 8, ast, visitors);
2769
2771
  return;
2770
2772
  default:
2771
- throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for ExportDefaultDeclarationKind`);
2773
+ throw new Error(
2774
+ `Unexpected discriminant ${ast.buffer[pos]} for ExportDefaultDeclarationKind`,
2775
+ );
2772
2776
  }
2773
2777
  }
2774
2778
 
@@ -4390,10 +4394,10 @@ function walkTSImportType(pos, ast, visitors) {
4390
4394
  if (enter !== null) enter(node);
4391
4395
  }
4392
4396
 
4393
- walkTSType(pos + 8, ast, visitors);
4394
- walkOptionBoxObjectExpression(pos + 24, ast, visitors);
4395
- walkOptionTSImportTypeQualifier(pos + 32, ast, visitors);
4396
- walkOptionBoxTSTypeParameterInstantiation(pos + 48, ast, visitors);
4397
+ walkStringLiteral(pos + 8, ast, visitors);
4398
+ walkOptionBoxObjectExpression(pos + 56, ast, visitors);
4399
+ walkOptionTSImportTypeQualifier(pos + 64, ast, visitors);
4400
+ walkOptionBoxTSTypeParameterInstantiation(pos + 80, ast, visitors);
4397
4401
 
4398
4402
  if (exit !== null) exit(node);
4399
4403
  }