Skip to content

Commit

Permalink
fix: expose string fragments in template string types
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumebrunerie authored and amaanq committed Feb 10, 2024
1 parent 7db8390 commit 72f8aaf
Show file tree
Hide file tree
Showing 9 changed files with 489,444 additions and 489,471 deletions.
6 changes: 4 additions & 2 deletions common/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ T as {} & { [t: T]: T } & { [g: G]: G }
(expression_statement
(as_expression
(identifier)
(template_literal_type)))
(template_literal_type
(string_fragment))))
(expression_statement
(as_expression
(identifier)
Expand Down Expand Up @@ -57,7 +58,8 @@ T satisfies {} & { [t: T]: T } & { [g: G]: G }
(expression_statement
(satisfies_expression
(identifier)
(template_literal_type)))
(template_literal_type
(string_fragment))))
(expression_statement
(satisfies_expression
(identifier)
Expand Down
13 changes: 10 additions & 3 deletions common/corpus/types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1765,8 +1765,10 @@ type StringToNumber<S extends string> = S extends `${infer N extends number}` ?
(type_identifier)
(literal_type
(number))))
(string_fragment)
(template_type
(type_identifier))
(string_fragment)
(template_type
(generic_type
(type_identifier)
Expand All @@ -1776,13 +1778,15 @@ type StringToNumber<S extends string> = S extends `${infer N extends number}` ?
(type_alias_declaration
(type_identifier)
(template_literal_type
(string_fragment)
(template_type
(literal_type
(string
(string_fragment))))
(template_type
(literal_type
(number)))))
(number)))
(string_fragment)))
(type_alias_declaration
(type_identifier)
(type_parameters
Expand Down Expand Up @@ -1886,6 +1890,7 @@ type A<B> = { [B in keyof C & string as `${P}1` | `${P}2`]: A[B] }
(type_identifier))
(predefined_type))
(template_literal_type
(string_fragment)
(template_type
(generic_type
(type_identifier)
Expand Down Expand Up @@ -1913,10 +1918,12 @@ type A<B> = { [B in keyof C & string as `${P}1` | `${P}2`]: A[B] }
(union_type
(template_literal_type
(template_type
(type_identifier)))
(type_identifier))
(string_fragment))
(template_literal_type
(template_type
(type_identifier)))))
(type_identifier))
(string_fragment))))
(type_annotation
(lookup_type
(type_identifier)
Expand Down
2 changes: 1 addition & 1 deletion common/define-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ module.exports = function defineGrammar(dialect) {
template_literal_type: ($) => seq(
'`',
repeat(choice(
$._template_chars,
alias($._template_chars, $.string_fragment),
$.template_type,
)),
'`',
Expand Down
10 changes: 7 additions & 3 deletions tsx/src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 72f8aaf

Please sign in to comment.