Let’s say I have type Foo
:
type Foo = 'apple' | `a.${number}` | `a.${number}.c`
Eventually I want to convert it to Boo
:
type Boo = ReplaceTemplateWithLiteral<Foo>
// 'apple' | 'a.${number}' | 'a.${number}.c'
I know that I can extract string type that includes ${number}
by:
Extract<Foo, `${string}.${number}` | `${string}.${number}.${string}`>
// `a.${number}` | `a.${number}.c`
But I don’t know how to convert it to 'a.${number}' | 'a.${number}.c'
which is just string literals.
Is this even possible?
1