@willbooster/tree-sitter-typescript 1.1.1 → 1.1.2

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.
@@ -84,7 +84,11 @@ module.exports = function defineGrammar(dialect) {
84
84
  [$._parameter_name, $.primary_type],
85
85
  [$.pattern, $.primary_type],
86
86
 
87
- [$.optional_tuple_parameter, $.primary_type],
87
+ [$._tuple_label, $.primary_type],
88
+ [$._tuple_label, $.literal_type],
89
+ [$._tuple_label, $.index_type_query],
90
+ [$._tuple_label, $.readonly_type],
91
+ [$._tuple_label, $.predefined_type],
88
92
  [$.rest_pattern, $.primary_type, $.primary_expression],
89
93
 
90
94
  [$.object, $.object_type],
@@ -625,9 +629,46 @@ module.exports = function defineGrammar(dialect) {
625
629
  ),
626
630
 
627
631
  tuple_parameter: ($) =>
628
- seq(field('name', choice($.identifier, $.rest_pattern)), field('type', $.type_annotation)),
632
+ seq(
633
+ field('name', choice($._tuple_label, alias($._tuple_rest_label, $.rest_pattern))),
634
+ field('type', $.type_annotation)
635
+ ),
636
+
637
+ optional_tuple_parameter: ($) => seq(field('name', $._tuple_label), '?', field('type', $.type_annotation)),
629
638
 
630
- optional_tuple_parameter: ($) => seq(field('name', $.identifier), '?', field('type', $.type_annotation)),
639
+ _tuple_rest_label: ($) => seq('...', $._tuple_label),
640
+
641
+ // TypeScript accepts any identifier name as a tuple label, but where a tuple member begins, the keywords that
642
+ // can begin a type are lexed as those keywords, so they are listed here. Keywords that are rules of their own
643
+ // are aliased as rules: repeating their strings would turn those rules into nodes that wrap a token.
644
+ _tuple_label: ($) =>
645
+ choice(
646
+ $.identifier,
647
+ alias(
648
+ choice(
649
+ 'any',
650
+ 'number',
651
+ 'boolean',
652
+ 'string',
653
+ 'symbol',
654
+ 'void',
655
+ 'unknown',
656
+ 'never',
657
+ 'object',
658
+ 'readonly',
659
+ 'keyof',
660
+ 'infer',
661
+ 'typeof',
662
+ 'new',
663
+ 'const',
664
+ 'unique',
665
+ 'abstract',
666
+ 'import'
667
+ ),
668
+ $.identifier
669
+ ),
670
+ alias(choice($.undefined, $.null, $.true, $.false, $.this), $.identifier)
671
+ ),
631
672
 
632
673
  optional_type: ($) => seq($.type, '?'),
633
674
  rest_type: ($) => seq('...', $.type),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-typescript",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "TypeScript and TSX grammars for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
Binary file
package/tree-sitter.json CHANGED
@@ -77,7 +77,7 @@
77
77
  }
78
78
  ],
79
79
  "metadata": {
80
- "version": "1.1.1",
80
+ "version": "1.1.2",
81
81
  "license": "MIT",
82
82
  "description": "TypeScript and TSX grammars for tree-sitter",
83
83
  "authors": [