Skip to content

Commit 198e2ea

Browse files
guillaumebrunerieamaanq
authored andcommitted
fix: expose string fragments in template string types
1 parent 4d6a81c commit 198e2ea

File tree

9 files changed

+489444
-489471
lines changed

9 files changed

+489444
-489471
lines changed

common/corpus/expressions.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ T as {} & { [t: T]: T } & { [g: G]: G }
1212
(expression_statement
1313
(as_expression
1414
(identifier)
15-
(template_literal_type)))
15+
(template_literal_type
16+
(string_fragment))))
1617
(expression_statement
1718
(as_expression
1819
(identifier)
@@ -57,7 +58,8 @@ T satisfies {} & { [t: T]: T } & { [g: G]: G }
5758
(expression_statement
5859
(satisfies_expression
5960
(identifier)
60-
(template_literal_type)))
61+
(template_literal_type
62+
(string_fragment))))
6163
(expression_statement
6264
(satisfies_expression
6365
(identifier)

common/corpus/types.txt

+10-3
Original file line numberDiff line numberDiff line change
@@ -1765,8 +1765,10 @@ type StringToNumber<S extends string> = S extends `${infer N extends number}` ?
17651765
(type_identifier)
17661766
(literal_type
17671767
(number))))
1768+
(string_fragment)
17681769
(template_type
17691770
(type_identifier))
1771+
(string_fragment)
17701772
(template_type
17711773
(generic_type
17721774
(type_identifier)
@@ -1776,13 +1778,15 @@ type StringToNumber<S extends string> = S extends `${infer N extends number}` ?
17761778
(type_alias_declaration
17771779
(type_identifier)
17781780
(template_literal_type
1781+
(string_fragment)
17791782
(template_type
17801783
(literal_type
17811784
(string
17821785
(string_fragment))))
17831786
(template_type
17841787
(literal_type
1785-
(number)))))
1788+
(number)))
1789+
(string_fragment)))
17861790
(type_alias_declaration
17871791
(type_identifier)
17881792
(type_parameters
@@ -1886,6 +1890,7 @@ type A<B> = { [B in keyof C & string as `${P}1` | `${P}2`]: A[B] }
18861890
(type_identifier))
18871891
(predefined_type))
18881892
(template_literal_type
1893+
(string_fragment)
18891894
(template_type
18901895
(generic_type
18911896
(type_identifier)
@@ -1913,10 +1918,12 @@ type A<B> = { [B in keyof C & string as `${P}1` | `${P}2`]: A[B] }
19131918
(union_type
19141919
(template_literal_type
19151920
(template_type
1916-
(type_identifier)))
1921+
(type_identifier))
1922+
(string_fragment))
19171923
(template_literal_type
19181924
(template_type
1919-
(type_identifier)))))
1925+
(type_identifier))
1926+
(string_fragment))))
19201927
(type_annotation
19211928
(lookup_type
19221929
(type_identifier)

common/define-grammar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ module.exports = function defineGrammar(dialect) {
749749
template_literal_type: ($) => seq(
750750
'`',
751751
repeat(choice(
752-
$._template_chars,
752+
alias($._template_chars, $.string_fragment),
753753
$.template_type,
754754
)),
755755
'`',

tsx/src/grammar.json

+7-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsx/src/node-types.json

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)