Type Challenges Judge

Trim Right

提出詳細

type Trimable = " " | "\n" | "\t"; type TrimRight<S extends string> = S extends `${infer Tail}${Trimable}` ? TrimRight<Tail>:S;
提出日時2022-06-27 12:31:45
問題Trim Right
ユーザーwaki285
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<TrimRight<'str'>, 'str'>>, Expect<Equal<TrimRight<'str '>, 'str'>>, Expect<Equal<TrimRight<'str '>, 'str'>>, Expect<Equal<TrimRight<' str '>, ' str'>>, Expect<Equal<TrimRight<' foo bar \n\t '>, ' foo bar'>>, Expect<Equal<TrimRight<''>, ''>>, Expect<Equal<TrimRight<'\n\t '>, ''>>, ]