Index
Type aliases
Type aliases
Try
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'
Similar to
Cast
but with a custom fallbackCatch
. If it fails, it will enforceCatch
instead ofA2
.