Skip to content

OmitByValue

Constructs a type by omitting all entries of T whose values extend V.

Optional properties are matched by their non-nullable value type, so an optional string property is omitted the same as a required one.

Available since v3.0.0

import type { OmitByValue } from '@helpers4/type';
// or, from the all-in-one package (same code, one install):
import type { OmitByValue } from 'helpers4/type';
type OmitByValue<T, V> = Omit<T, KeysOfType<T, V>>
type Form = { name: string; age: number; email: string; active: boolean };
type NonStringFields = OmitByValue<Form, string>; // { age: number; active: boolean }

View source on GitHub