Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "Any/Try"

Index

Type aliases

Type aliases

Try

Try<A1, A2, Catch>: Try<A1, A2, 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 A1 with

  • Catch

    to fallback (fail)

returns

A1 or 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'

Made with ❤️ by pirix-gh. Documentation generated by TypeDoc.