Trim Left
提出詳細
type Includes<T extends readonly any[], U> = T extends [infer F, ...infer R] ? Equal<F, U> extends true ? true : Includes<R, U> : false type WhiteSpace = [" ", "\n", "\r", "\t"] type TrimLeft<S extends string> = S extends `${infer L}${infer R}` ? Includes<WhiteSpace, L> extends true ? TrimLeft<R> : S : ""
提出日時 | 2023-08-08 08:07:40 |
---|---|
問題 | Trim Left |
ユーザー | ookkoouu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<TrimLeft<'str'>, 'str'>>, Expect<Equal<TrimLeft<' str'>, 'str'>>, Expect<Equal<TrimLeft<' str'>, 'str'>>, Expect<Equal<TrimLeft<' str '>, 'str '>>, Expect<Equal<TrimLeft<' \n\t foo bar '>, 'foo bar '>>, Expect<Equal<TrimLeft<''>, ''>>, Expect<Equal<TrimLeft<' \n\t'>, ''>>, ]