Options
All
  • Public
  • Public/Protected
  • All
Menu

Type aliases

Type aliases

Cast

Cast<A1, A2>: A1 extends A2 ? A1 : A2

Ask TS to re-check that A1 extends A2. And if it fails, A2 will be enforced anyway. Can also be used to add constraints on parameters.

Type parameters

  • A1: any

    to check against

  • A2: any

    to cast to

returns

A1 | A2

example

import {A} from 'ts-toolbelt'

type test0 = A.Cast<'42', string> // '42'
type test1 = A.Cast<'42', number> // number

  • Inherited
  • Protected
  • Private
  • Static
  • Module
  • Object
  • Property
  • Function
  • Variable
  • Index
  • Type
  • Class
  • Interface
  • Enum
  • Constructor
  • Getter/Setter
Made with ❤️ by pirix-gh. Documentation generated by TypeDoc.