@willbooster/tree-sitter-typescript 1.3.3 → 1.3.5
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 +38 -17
- 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],
|
|
@@ -145,6 +146,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
145
146
|
],
|
|
146
147
|
|
|
147
148
|
conflicts: ($, previous) => [
|
|
149
|
+
[$.import_specifier, $._module_export_name],
|
|
148
150
|
[$.export_specifier, $._local_export_specifier, $._module_export_name],
|
|
149
151
|
[$.export_specifier, $._module_export_name],
|
|
150
152
|
[$.export_specifier, $._local_export_specifier],
|
|
@@ -389,6 +391,23 @@ module.exports = function defineGrammar(dialect) {
|
|
|
389
391
|
|
|
390
392
|
_lhs_expression: ($, previous) => choice(previous, $.non_null_expression),
|
|
391
393
|
|
|
394
|
+
await_expression: (_, previous) => {
|
|
395
|
+
const members = previous.content.content.members;
|
|
396
|
+
const guardIndex = members.findIndex(
|
|
397
|
+
(member) => member.type === 'SYMBOL' && member.name === '_await_operand_end'
|
|
398
|
+
);
|
|
399
|
+
if (guardIndex === -1) {
|
|
400
|
+
throw new Error('JavaScript await_expression must have a bare _await_operand_end member');
|
|
401
|
+
}
|
|
402
|
+
return {
|
|
403
|
+
...previous,
|
|
404
|
+
content: {
|
|
405
|
+
...previous.content,
|
|
406
|
+
content: seq(...members.map((member, index) => (index === guardIndex ? optional(member) : member))),
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
},
|
|
410
|
+
|
|
392
411
|
primary_expression: ($) =>
|
|
393
412
|
choice($._type_arguments_target, alias($._argumentless_new_expression, $.new_expression)),
|
|
394
413
|
|
|
@@ -396,20 +415,19 @@ module.exports = function defineGrammar(dialect) {
|
|
|
396
415
|
// after `new A` to the `new` (`new A<T>()`, `new new A<T>()`), so a `new` without arguments takes none.
|
|
397
416
|
_type_arguments_target: ($) => {
|
|
398
417
|
const members = JavaScript.grammar.rules.primary_expression.members.filter(
|
|
399
|
-
(member) =>
|
|
418
|
+
(member) =>
|
|
419
|
+
(member.type !== 'ALIAS' || member.content.name !== '_argumentless_new_expression') &&
|
|
420
|
+
(dialect !== 'typescript' || member.name !== '_jsx_element')
|
|
400
421
|
);
|
|
401
422
|
return choice(...members, $.non_null_expression);
|
|
402
423
|
},
|
|
403
424
|
|
|
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
425
|
expression: ($, previous) => {
|
|
407
426
|
const choices = [$.as_expression, $.satisfies_expression, $.instantiation_expression, $.internal_module];
|
|
408
427
|
const members = previous.members;
|
|
409
428
|
|
|
410
429
|
if (dialect === 'typescript') {
|
|
411
|
-
choices.push($.type_assertion);
|
|
412
|
-
choices.push(...members.filter((member) => member.name !== '_jsx_element'));
|
|
430
|
+
choices.push($.type_assertion, ...members);
|
|
413
431
|
} else if (dialect === 'tsx') {
|
|
414
432
|
choices.push(...members);
|
|
415
433
|
} else {
|
|
@@ -496,14 +514,14 @@ module.exports = function defineGrammar(dialect) {
|
|
|
496
514
|
|
|
497
515
|
_import_identifier: ($) => choice($.identifier, alias('type', $.identifier)),
|
|
498
516
|
|
|
499
|
-
import_specifier: ($) =>
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
517
|
+
import_specifier: ($) => {
|
|
518
|
+
const name = choice($._import_identifier, alias('as', $.identifier));
|
|
519
|
+
const specifier = choice(
|
|
520
|
+
field('name', name),
|
|
521
|
+
seq(field('name', choice($._module_export_name, alias('as', $.identifier))), 'as', field('alias', name))
|
|
522
|
+
);
|
|
523
|
+
return choice(specifier, prec.dynamic(1, seq('type', specifier)));
|
|
524
|
+
},
|
|
507
525
|
|
|
508
526
|
import_attribute: ($) => seq(choice('with', 'assert'), $.object),
|
|
509
527
|
|
|
@@ -537,14 +555,14 @@ module.exports = function defineGrammar(dialect) {
|
|
|
537
555
|
// variable named `using`.
|
|
538
556
|
using_declaration: ($) =>
|
|
539
557
|
seq(
|
|
540
|
-
field('kind', choice('using', seq('await', 'using'))),
|
|
558
|
+
field('kind', choice('using', seq(alias($._await_keyword, 'await'), 'using'))),
|
|
541
559
|
commaSep1(alias($._using_declarator, $.variable_declarator)),
|
|
542
560
|
$._semicolon
|
|
543
561
|
),
|
|
544
562
|
|
|
545
563
|
_for_using_declaration: ($) =>
|
|
546
564
|
seq(
|
|
547
|
-
field('kind', choice('using', seq('await', 'using'))),
|
|
565
|
+
field('kind', choice('using', seq(alias($._await_keyword, 'await'), 'using'))),
|
|
548
566
|
commaSep1(alias($._using_declarator, $.variable_declarator)),
|
|
549
567
|
';'
|
|
550
568
|
),
|
|
@@ -570,7 +588,10 @@ module.exports = function defineGrammar(dialect) {
|
|
|
570
588
|
field('kind', choice('let', 'const')),
|
|
571
589
|
field('left', choice($._binding_identifier, $._destructuring_pattern))
|
|
572
590
|
),
|
|
573
|
-
seq(
|
|
591
|
+
seq(
|
|
592
|
+
field('kind', choice('using', seq(alias($._await_keyword, 'await'), 'using'))),
|
|
593
|
+
field('left', $._binding_identifier)
|
|
594
|
+
)
|
|
574
595
|
),
|
|
575
596
|
field('operator', choice('in', 'of')),
|
|
576
597
|
field('right', $._expressions),
|
|
@@ -810,7 +831,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
810
831
|
|
|
811
832
|
module: ($) => seq('module', $._module),
|
|
812
833
|
|
|
813
|
-
internal_module: ($) => seq('namespace', $._module),
|
|
834
|
+
internal_module: ($) => seq('namespace', $._module, optional($._namespace_expression_end)),
|
|
814
835
|
|
|
815
836
|
global_declaration: ($) =>
|
|
816
837
|
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.5",
|
|
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
|