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 '>, ''>>, ]