Type Challenges Judge

Trim Left

提出詳細

type WhiteSpace = " " | "\n" | "\t" type TrimLeft<S extends string> = S extends `${infer First}${infer Rest}` ? (First extends WhiteSpace ? TrimLeft<Rest> : S) : S
提出日時2023-09-13 14:07:44
問題Trim Left
ユーザーsankantsu
ステータス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'>, ''>>, ]