@willbooster/tree-sitter-typescript 1.2.1 → 1.2.3
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 +48 -3
- package/package.json +1 -1
- package/tree-sitter-tsx.wasm +0 -0
- package/tree-sitter-typescript.wasm +0 -0
- package/tree-sitter.json +1 -1
package/common/defineGrammar.js
CHANGED
|
@@ -59,6 +59,9 @@ module.exports = function defineGrammar(dialect) {
|
|
|
59
59
|
|
|
60
60
|
conflicts: ($, previous) => [
|
|
61
61
|
...previous,
|
|
62
|
+
[$.primary_expression, $.using_declaration],
|
|
63
|
+
[$.primary_expression, $._for_header, $._for_using_declaration],
|
|
64
|
+
[$._for_header, $._binding_identifier],
|
|
62
65
|
[$.expression, $.call_expression, $.instantiation_expression],
|
|
63
66
|
|
|
64
67
|
// This appears to be necessary to parse a parenthesized class expression
|
|
@@ -338,19 +341,60 @@ module.exports = function defineGrammar(dialect) {
|
|
|
338
341
|
field('body', $.statement)
|
|
339
342
|
),
|
|
340
343
|
|
|
344
|
+
// ECMAScript binds only identifiers in a using declaration, so `using [a] = b` assigns to a subscript of a
|
|
345
|
+
// variable named `using`.
|
|
346
|
+
using_declaration: ($) =>
|
|
347
|
+
seq(
|
|
348
|
+
field('kind', choice('using', seq('await', 'using'))),
|
|
349
|
+
commaSep1(alias($._using_declarator, $.variable_declarator)),
|
|
350
|
+
$._semicolon
|
|
351
|
+
),
|
|
352
|
+
|
|
341
353
|
_for_using_declaration: ($) =>
|
|
342
|
-
seq(
|
|
354
|
+
seq(
|
|
355
|
+
field('kind', choice('using', seq('await', 'using'))),
|
|
356
|
+
commaSep1(alias($._using_declarator, $.variable_declarator)),
|
|
357
|
+
';'
|
|
358
|
+
),
|
|
359
|
+
|
|
360
|
+
_using_declarator: ($) =>
|
|
361
|
+
seq(field('name', $._binding_identifier), field('type', optional($.type_annotation)), optional($._initializer)),
|
|
362
|
+
|
|
363
|
+
// After a declaration keyword that may also be an identifier (`let`, `using`), the lexer reads `of`, `as`, and
|
|
364
|
+
// `satisfies` as the keywords that could follow that identifier, and every declaration shares that lexer state.
|
|
365
|
+
_binding_identifier: ($) => choice($.identifier, alias(choice('of', 'as', 'satisfies'), $.identifier)),
|
|
366
|
+
|
|
367
|
+
_for_header: ($) =>
|
|
368
|
+
seq(
|
|
369
|
+
'(',
|
|
370
|
+
choice(
|
|
371
|
+
field('left', choice($._lhs_expression, $.parenthesized_expression)),
|
|
372
|
+
seq(
|
|
373
|
+
field('kind', 'var'),
|
|
374
|
+
field('left', choice($._binding_identifier, $._destructuring_pattern)),
|
|
375
|
+
optional($._initializer)
|
|
376
|
+
),
|
|
377
|
+
seq(
|
|
378
|
+
field('kind', choice('let', 'const')),
|
|
379
|
+
field('left', choice($._binding_identifier, $._destructuring_pattern))
|
|
380
|
+
),
|
|
381
|
+
seq(field('kind', choice('using', seq('await', 'using'))), field('left', $._binding_identifier))
|
|
382
|
+
),
|
|
383
|
+
field('operator', choice('in', 'of')),
|
|
384
|
+
field('right', $._expressions),
|
|
385
|
+
')'
|
|
386
|
+
),
|
|
343
387
|
|
|
344
388
|
non_null_expression: ($) => prec.left('unary', seq($.expression, '!')),
|
|
345
389
|
|
|
346
390
|
variable_declarator: ($) =>
|
|
347
391
|
choice(
|
|
348
392
|
seq(
|
|
349
|
-
field('name', choice($.
|
|
393
|
+
field('name', choice($._binding_identifier, $._destructuring_pattern)),
|
|
350
394
|
field('type', optional($.type_annotation)),
|
|
351
395
|
optional($._initializer)
|
|
352
396
|
),
|
|
353
|
-
prec('declaration', seq(field('name', $.
|
|
397
|
+
prec('declaration', seq(field('name', $._binding_identifier), '!', field('type', $.type_annotation)))
|
|
354
398
|
),
|
|
355
399
|
|
|
356
400
|
method_signature: ($) =>
|
|
@@ -1088,6 +1132,7 @@ module.exports = function defineGrammar(dialect) {
|
|
|
1088
1132
|
'object',
|
|
1089
1133
|
'new',
|
|
1090
1134
|
'readonly',
|
|
1135
|
+
'using',
|
|
1091
1136
|
previous
|
|
1092
1137
|
),
|
|
1093
1138
|
},
|
package/package.json
CHANGED
package/tree-sitter-tsx.wasm
CHANGED
|
Binary file
|
|
Binary file
|