@willbooster/tree-sitter-typescript 1.1.1 → 1.1.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 +54 -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],
|
|
@@ -163,6 +167,16 @@ module.exports = function defineGrammar(dialect) {
|
|
|
163
167
|
field('arguments', $.arguments)
|
|
164
168
|
)
|
|
165
169
|
),
|
|
170
|
+
// A tag with type arguments is parsed like a generic call. Optional type arguments in the `template_call`
|
|
171
|
+
// alternative below would make the parser commit to a tagged template at the `<` of `f<T>(x)`.
|
|
172
|
+
prec(
|
|
173
|
+
'call',
|
|
174
|
+
seq(
|
|
175
|
+
field('function', $.expression),
|
|
176
|
+
field('type_arguments', $.type_arguments),
|
|
177
|
+
field('arguments', $.template_string)
|
|
178
|
+
)
|
|
179
|
+
),
|
|
166
180
|
prec(
|
|
167
181
|
'template_call',
|
|
168
182
|
seq(
|
|
@@ -625,9 +639,46 @@ module.exports = function defineGrammar(dialect) {
|
|
|
625
639
|
),
|
|
626
640
|
|
|
627
641
|
tuple_parameter: ($) =>
|
|
628
|
-
seq(
|
|
642
|
+
seq(
|
|
643
|
+
field('name', choice($._tuple_label, alias($._tuple_rest_label, $.rest_pattern))),
|
|
644
|
+
field('type', $.type_annotation)
|
|
645
|
+
),
|
|
629
646
|
|
|
630
|
-
optional_tuple_parameter: ($) => seq(field('name', $.
|
|
647
|
+
optional_tuple_parameter: ($) => seq(field('name', $._tuple_label), '?', field('type', $.type_annotation)),
|
|
648
|
+
|
|
649
|
+
_tuple_rest_label: ($) => seq('...', $._tuple_label),
|
|
650
|
+
|
|
651
|
+
// TypeScript accepts any identifier name as a tuple label, but where a tuple member begins, the keywords that
|
|
652
|
+
// can begin a type are lexed as those keywords, so they are listed here. Keywords that are rules of their own
|
|
653
|
+
// are aliased as rules: repeating their strings would turn those rules into nodes that wrap a token.
|
|
654
|
+
_tuple_label: ($) =>
|
|
655
|
+
choice(
|
|
656
|
+
$.identifier,
|
|
657
|
+
alias(
|
|
658
|
+
choice(
|
|
659
|
+
'any',
|
|
660
|
+
'number',
|
|
661
|
+
'boolean',
|
|
662
|
+
'string',
|
|
663
|
+
'symbol',
|
|
664
|
+
'void',
|
|
665
|
+
'unknown',
|
|
666
|
+
'never',
|
|
667
|
+
'object',
|
|
668
|
+
'readonly',
|
|
669
|
+
'keyof',
|
|
670
|
+
'infer',
|
|
671
|
+
'typeof',
|
|
672
|
+
'new',
|
|
673
|
+
'const',
|
|
674
|
+
'unique',
|
|
675
|
+
'abstract',
|
|
676
|
+
'import'
|
|
677
|
+
),
|
|
678
|
+
$.identifier
|
|
679
|
+
),
|
|
680
|
+
alias(choice($.undefined, $.null, $.true, $.false, $.this), $.identifier)
|
|
681
|
+
),
|
|
631
682
|
|
|
632
683
|
optional_type: ($) => seq($.type, '?'),
|
|
633
684
|
rest_type: ($) => seq('...', $.type),
|
package/package.json
CHANGED
package/tree-sitter-tsx.wasm
CHANGED
|
Binary file
|
|
Binary file
|