@willbooster/tree-sitter-typescript 1.2.2 → 1.2.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.
@@ -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(field('kind', choice('using', seq('await', 'using'))), commaSep1($.variable_declarator), ';'),
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($.identifier, alias('of', $.identifier), $._destructuring_pattern)),
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', $.identifier), '!', field('type', $.type_annotation)))
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-typescript",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "TypeScript and TSX grammars for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -43,14 +43,13 @@
43
43
  "verify-full": "bun wb verify --full"
44
44
  },
45
45
  "devDependencies": {
46
- "@semantic-release/exec": "7.1.0",
47
46
  "@tsconfig/bun": "1.0.11",
48
47
  "@types/bun": "1.4.2",
49
48
  "@vitest/browser-playwright": "5.0.1",
50
49
  "@willbooster/oxfmt-config": "1.2.2",
51
50
  "@willbooster/oxlint-config": "1.4.8",
52
51
  "@willbooster/tree-sitter-javascript": "1.0.3",
53
- "@willbooster/wb": "22.11.5",
52
+ "@willbooster/wb": "22.13.0",
54
53
  "@willbooster/web-tree-sitter": "1.0.7",
55
54
  "conventional-changelog-conventionalcommits": "10.4.0",
56
55
  "lefthook": "2.1.14",
Binary file
Binary file
package/tree-sitter.json CHANGED
@@ -77,7 +77,7 @@
77
77
  }
78
78
  ],
79
79
  "metadata": {
80
- "version": "1.2.2",
80
+ "version": "1.2.4",
81
81
  "license": "MIT",
82
82
  "description": "TypeScript and TSX grammars for tree-sitter",
83
83
  "authors": [