typedash
Version:
modern, type-safe collection of utility functions
13 lines (9 loc) • 607 B
TypeScript
import { C as CastToString } from './CastToString-BoaHrryS.js';
import { K as KeysOfUnion } from './KeysOfUnion-BrkZWXzm.js';
import { Get, UnionToIntersection } from 'type-fest';
/**
* Similar to `T[K]`, but gets the value of all the types in a union.
*/
type PropertyValueOfUnion<T extends object, K extends KeysOfUnion<T>> = Get<UnionToIntersection<T>, K & string>;
type ObjectPredicate<T extends object> = (value: Exclude<PropertyValueOfUnion<T, KeysOfUnion<T>>, undefined>, key: CastToString<KeysOfUnion<T>>, object: T) => boolean;
export type { ObjectPredicate as O, PropertyValueOfUnion as P };