@willbooster/tree-sitter-typescript 1.1.0 → 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),
@@ -701,7 +742,14 @@ module.exports = function defineGrammar(dialect) {
701
742
  prec(
702
743
  'call',
703
744
  seq(
704
- field('name', choice($._type_identifier, $.nested_type_identifier)),
745
+ field(
746
+ 'name',
747
+ choice(
748
+ $._type_identifier,
749
+ $.nested_type_identifier,
750
+ alias($._type_query_member_expression_in_type_annotation, $.member_expression)
751
+ )
752
+ ),
705
753
  field('type_arguments', $.type_arguments)
706
754
  )
707
755
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-typescript",
3
- "version": "1.1.0",
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.0",
80
+ "version": "1.1.2",
81
81
  "license": "MIT",
82
82
  "description": "TypeScript and TSX grammars for tree-sitter",
83
83
  "authors": [
@@ -2695,6 +2695,10 @@
2695
2695
  "multiple": false,
2696
2696
  "required": true,
2697
2697
  "types": [
2698
+ {
2699
+ "type": "member_expression",
2700
+ "named": true
2701
+ },
2698
2702
  {
2699
2703
  "type": "nested_type_identifier",
2700
2704
  "named": true
@@ -2691,6 +2691,10 @@
2691
2691
  "multiple": false,
2692
2692
  "required": true,
2693
2693
  "types": [
2694
+ {
2695
+ "type": "member_expression",
2696
+ "named": true
2697
+ },
2694
2698
  {
2695
2699
  "type": "nested_type_identifier",
2696
2700
  "named": true