Type Challenges Judge

Trim

提出詳細

type Trim<T extends string> = T extends `${TrimTarget}${infer Tail}` ? Trim<Tail> : T extends `${infer Head}${TrimTarget}` ? Trim<Head> : T
提出日時2023-05-03 04:53:05
問題Trim
ユーザーDowanna
ステータスWrong Answer
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Trim<'str'>, 'str'>>, Expect<Equal<Trim<' str'>, 'str'>>, Expect<Equal<Trim<' str'>, 'str'>>, Expect<Equal<Trim<'str '>, 'str'>>, Expect<Equal<Trim<' str '>, 'str'>>, Expect<Equal<Trim<' \n\t foo bar \t'>, 'foo bar'>>, Expect<Equal<Trim<''>, ''>>, Expect<Equal<Trim<' \n\t '>, ''>>, ]