Type alias OmitExactlyByType<T, P>

OmitExactlyByType<T, P>: {
    [K in Keys<T> as If<Equals<T[K], P>, never, K>]: T[K]
}

Get a set of properties from T whose type exactly matches P.

Type Parameters

  • T
  • P

Example

type OneLevelDeep = {
foo: boolean;
bar?: Numeric;
baz: Nullable;
fooBaz: bigint;
bazFoo: string | boolean;
};
type A = OmitExactlyByType<OneLevelDeep, bigint>
// A results in:
{
foo: boolean;
bar?: Numeric;
baz: Nullable;
bazFoo: string | boolean;
}
type B = OmitExactlyByType<OneLevelDeep, string | boolean>
// B results in
{
foo: boolean;
bar?: Numeric;
baz: Nullable;
fooBaz: bigint;
}