Options
All
  • Public
  • Public/Protected
  • All
Menu

Type aliases

Type aliases

Try

Try<A1, A2, Catch>: A1 extends A2 ? A1 : Catch

Similar to Cast but with a custom fallback Catch. If it fails, it will enforce Catch instead of A2.

Type parameters

  • A1: any

    to check against

  • A2: any

    to try/test with

  • Catch

    to fallback to if the test failed

returns

A1 | Catch

example

import {A} from 'ts-toolbelt'

type test0 = A.Try<'42', string>          // '42'
type test1 = A.Try<'42', number>          // never
type test1 = A.Try<'42', number, 'tried'> // 'tried'

  • 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.