@willbooster/tree-sitter-typescript 1.3.3 → 1.3.4
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.
- package/common/defineGrammar.js +29 -9
- package/package.json +2 -2
- package/tree-sitter-tsx.wasm +0 -0
- package/tree-sitter-typescript.wasm +0 -0
- package/tree-sitter.json +1 -1
- package/tsx/src/node-types.json +16 -8
package/common/defineGrammar.js
CHANGED
|
@@ -70,6 +70,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
70
70
|
$._global_declaration_start,
|
|
71
71
|
$._global_declaration_end,
|
|
72
72
|
$.__error_recovery,
|
|
73
|
+
$._namespace_expression_end,
|
|
73
74
|
],
|
|
74
75
|
|
|
75
76
|
supertypes: ($, previous) => [...previous, $.type, $.primary_type],
|
|
@@ -389,6 +390,23 @@ module.exports = function defineGrammar(dialect) {
|
|
|
389
390
|
|
|
390
391
|
_lhs_expression: ($, previous) => choice(previous, $.non_null_expression),
|
|
391
392
|
|
|
393
|
+
await_expression: (_, previous) => {
|
|
394
|
+
const members = previous.content.content.members;
|
|
395
|
+
const guardIndex = members.findIndex(
|
|
396
|
+
(member) => member.type === 'SYMBOL' && member.name === '_await_operand_end'
|
|
397
|
+
);
|
|
398
|
+
if (guardIndex === -1) {
|
|
399
|
+
throw new Error('JavaScript await_expression must have a bare _await_operand_end member');
|
|
400
|
+
}
|
|
401
|
+
return {
|
|
402
|
+
...previous,
|
|
403
|
+
content: {
|
|
404
|
+
...previous.content,
|
|
405
|
+
content: seq(...members.map((member, index) => (index === guardIndex ? optional(member) : member))),
|
|
406
|
+
},
|
|
407
|
+
};
|
|
408
|
+
},
|
|
409
|
+
|
|
392
410
|
primary_expression: ($) =>
|
|
393
411
|
choice($._type_arguments_target, alias($._argumentless_new_expression, $.new_expression)),
|
|
394
412
|
|
|
@@ -396,20 +414,19 @@ module.exports = function defineGrammar(dialect) {
|
|
|
396
414
|
// after `new A` to the `new` (`new A<T>()`, `new new A<T>()`), so a `new` without arguments takes none.
|
|
397
415
|
_type_arguments_target: ($) => {
|
|
398
416
|
const members = JavaScript.grammar.rules.primary_expression.members.filter(
|
|
399
|
-
(member) =>
|
|
417
|
+
(member) =>
|
|
418
|
+
(member.type !== 'ALIAS' || member.content.name !== '_argumentless_new_expression') &&
|
|
419
|
+
(dialect !== 'typescript' || member.name !== '_jsx_element')
|
|
400
420
|
);
|
|
401
421
|
return choice(...members, $.non_null_expression);
|
|
402
422
|
},
|
|
403
423
|
|
|
404
|
-
// If the dialect is regular typescript, we exclude JSX expressions and
|
|
405
|
-
// include type assertions. If the dialect is TSX, we do the opposite.
|
|
406
424
|
expression: ($, previous) => {
|
|
407
425
|
const choices = [$.as_expression, $.satisfies_expression, $.instantiation_expression, $.internal_module];
|
|
408
426
|
const members = previous.members;
|
|
409
427
|
|
|
410
428
|
if (dialect === 'typescript') {
|
|
411
|
-
choices.push($.type_assertion);
|
|
412
|
-
choices.push(...members.filter((member) => member.name !== '_jsx_element'));
|
|
429
|
+
choices.push($.type_assertion, ...members);
|
|
413
430
|
} else if (dialect === 'tsx') {
|
|
414
431
|
choices.push(...members);
|
|
415
432
|
} else {
|
|
@@ -537,14 +554,14 @@ module.exports = function defineGrammar(dialect) {
|
|
|
537
554
|
// variable named `using`.
|
|
538
555
|
using_declaration: ($) =>
|
|
539
556
|
seq(
|
|
540
|
-
field('kind', choice('using', seq('await', 'using'))),
|
|
557
|
+
field('kind', choice('using', seq(alias($._await_keyword, 'await'), 'using'))),
|
|
541
558
|
commaSep1(alias($._using_declarator, $.variable_declarator)),
|
|
542
559
|
$._semicolon
|
|
543
560
|
),
|
|
544
561
|
|
|
545
562
|
_for_using_declaration: ($) =>
|
|
546
563
|
seq(
|
|
547
|
-
field('kind', choice('using', seq('await', 'using'))),
|
|
564
|
+
field('kind', choice('using', seq(alias($._await_keyword, 'await'), 'using'))),
|
|
548
565
|
commaSep1(alias($._using_declarator, $.variable_declarator)),
|
|
549
566
|
';'
|
|
550
567
|
),
|
|
@@ -570,7 +587,10 @@ module.exports = function defineGrammar(dialect) {
|
|
|
570
587
|
field('kind', choice('let', 'const')),
|
|
571
588
|
field('left', choice($._binding_identifier, $._destructuring_pattern))
|
|
572
589
|
),
|
|
573
|
-
seq(
|
|
590
|
+
seq(
|
|
591
|
+
field('kind', choice('using', seq(alias($._await_keyword, 'await'), 'using'))),
|
|
592
|
+
field('left', $._binding_identifier)
|
|
593
|
+
)
|
|
574
594
|
),
|
|
575
595
|
field('operator', choice('in', 'of')),
|
|
576
596
|
field('right', $._expressions),
|
|
@@ -810,7 +830,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
810
830
|
|
|
811
831
|
module: ($) => seq('module', $._module),
|
|
812
832
|
|
|
813
|
-
internal_module: ($) => seq('namespace', $._module),
|
|
833
|
+
internal_module: ($) => seq('namespace', $._module, optional($._namespace_expression_end)),
|
|
814
834
|
|
|
815
835
|
global_declaration: ($) =>
|
|
816
836
|
seq(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-typescript",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "TypeScript and TSX grammars for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@vitest/browser-playwright": "5.0.2",
|
|
54
54
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
55
55
|
"@willbooster/oxlint-config": "1.4.8",
|
|
56
|
-
"@willbooster/tree-sitter-javascript": "1.0.
|
|
56
|
+
"@willbooster/tree-sitter-javascript": "1.0.25",
|
|
57
57
|
"@willbooster/wb": "22.18.0",
|
|
58
58
|
"@willbooster/web-tree-sitter": "1.0.17",
|
|
59
59
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
package/tree-sitter-tsx.wasm
CHANGED
|
Binary file
|
|
Binary file
|
package/tree-sitter.json
CHANGED
package/tsx/src/node-types.json
CHANGED
|
@@ -97,14 +97,6 @@
|
|
|
97
97
|
"type": "internal_module",
|
|
98
98
|
"named": true
|
|
99
99
|
},
|
|
100
|
-
{
|
|
101
|
-
"type": "jsx_element",
|
|
102
|
-
"named": true
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
"type": "jsx_self_closing_element",
|
|
106
|
-
"named": true
|
|
107
|
-
},
|
|
108
100
|
{
|
|
109
101
|
"type": "primary_expression",
|
|
110
102
|
"named": true
|
|
@@ -209,6 +201,14 @@
|
|
|
209
201
|
"type": "identifier",
|
|
210
202
|
"named": true
|
|
211
203
|
},
|
|
204
|
+
{
|
|
205
|
+
"type": "jsx_element",
|
|
206
|
+
"named": true
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"type": "jsx_self_closing_element",
|
|
210
|
+
"named": true
|
|
211
|
+
},
|
|
212
212
|
{
|
|
213
213
|
"type": "member_expression",
|
|
214
214
|
"named": true
|
|
@@ -3146,6 +3146,14 @@
|
|
|
3146
3146
|
"type": "identifier",
|
|
3147
3147
|
"named": true
|
|
3148
3148
|
},
|
|
3149
|
+
{
|
|
3150
|
+
"type": "jsx_element",
|
|
3151
|
+
"named": true
|
|
3152
|
+
},
|
|
3153
|
+
{
|
|
3154
|
+
"type": "jsx_self_closing_element",
|
|
3155
|
+
"named": true
|
|
3156
|
+
},
|
|
3149
3157
|
{
|
|
3150
3158
|
"type": "member_expression",
|
|
3151
3159
|
"named": true
|