string에서 특정한 Char를 없애라
Drop a specified char from a string.
type DropCharImplement<S extends string ,C extends string,Result extends string=''>=
S extends `${infer Start}${infer Last}`?
Start extends C?DropCharImplement<Last,C,Result>:DropCharImplement<Last,C,`${Result}${Start}`>
:Result
type DropChar<S extends string, C extends string>=DropCharImplement<S,C>
infer을 사용해 C와 같으면 Result에 넣지 않는 방식으로 타입을 구현했다.
type DropChar<S, C extends string> = S extends `${infer L}${C}${infer R}` ? DropChar<`${L}${R}`, C> : S;
다른 풀이가 있었다.
항상 다른 깔끔한 풀이가 존재하는 것 같다.
https://github.com/type-challenges/type-challenges/issues/2074