Type alias Trim<Input, TrimmedChars>

Trim<Input, TrimmedChars>: Input extends `${TrimmedChars}${infer InputSubstring}` | `${infer InputSubstring}${TrimmedChars}`
    ? Trim<InputSubstring, TrimmedChars>
    : Input

Takes an exact string type and returns a new string with the whitespace from both ends removed.

Type Parameters

  • Input extends string

    The exact string type.

  • TrimmedChars extends string = Space

    A union of string chars to trim.

Example

type trimmed = Trim<'  Hello World  '>
// => type trimmed = 'Hello World'

Generated using TypeDoc