UNPKG

type-fns

Version:

A set of types, type checks, and type guards for simpler, safer, and easier to read code.

13 lines (12 loc) 282 B
/** * asserts that an object has an id */ export type HasId<T> = T & { id: number; }; /** * checks whether not an object that may have an id does have the id, at runtime */ export declare const hasId: <T extends { id?: undefined | number; }>(obj: T) => obj is HasId<T>;