shaKY-iota / type-challenges

Collection of TypeScript type challenges with online judge
https://tsch.js.org/
MIT License
0 stars 0 forks source link

119 - ReplaceAll #20

Open shaKY-iota opened 2 years ago

shaKY-iota commented 2 years ago
// your answers
type ReplaceAll<S extends string, From extends string, To extends string> = From extends "" ? S : S extends `${infer First}${From}${infer Last}` ? `${ReplaceAll<First, From, To>}${To}${ReplaceAll<Last, From, To>}` : S