@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.
- package/common/defineGrammar.js +44 -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
|
@@ -84,7 +84,11 @@ module.exports = function defineGrammar(dialect) {
|
|
|
84
84
|
[$._parameter_name, $.primary_type],
|
|
85
85
|
[$.pattern, $.primary_type],
|
|
86
86
|
|
|
87
|
-
[$.
|
|
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(
|
|
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
|
-
|
|
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
package/tree-sitter-tsx.wasm
CHANGED
|
Binary file
|
|
Binary file
|