04803-medium-trim-right
Medium
template-literal

チャレンジのソース: type-challenges/04803-medium-trim-right

Implement TrimRight<T> which takes an exact string type and returns a new string with the whitespace ending removed.

For example:

type Trimed = TrimRight<'   Hello World    '> // expected to be '   Hello World'

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