Open
Description
Bug Report
🔎 Search Terms
infer conditional array rest unknown
🕗 Version & Regression Information
- I was unable to test this on prior versions than 4.1 because it uses template literal types added in 4.1
⏯ Playground Link
Playground link with relevant code
💻 Code
Using code from the #40336 description restricted to strings only:
type Join<S extends string[], D extends string> =
S extends [] ? '' :
S extends [string] ? `${S[0]}` :
S extends [string, ...infer R] ? `${S[0]}${D}${Join<R, D>}` :
string;
🙁 Actual behavior
R
is inferred as being unknown[]
.
🙂 Expected behavior
R
should be inferred as being string[]
.