import { IsAny } from 'type-fest'; /** * An extension of Extract for type predicates which falls back to the base * in order to narrow the `unknown` case. * * @example * function isMyType(data: T | MyType): data is NarrowedTo { ... } */ type NarrowedTo = Extract extends never ? Base : IsAny extends true ? Base : Extract; export type { NarrowedTo as N };