Skip to Content
typesWithFallback

WithFallback

See source on Github

Use TValue if truthy, otherwise use TFallback.

Example

type Example1 = WithFallback<null, 'fallback'> // 'fallback' type Example2 = WithFallback<{}, 'fallback'> // 'fallback' type Example3 = WithFallback<'value', 'fallback'> // 'value' type Example4 = WithFallback<{ key: 'val' }, 'fallback'> // { key: 'val' }