Sha256: 8c44636cd32c9f5279e967d56e67d7623341d90382871adf63eb9ba427a3f820
Contents?: true
Size: 725 Bytes
Versions: 28
Compression:
Stored size: 725 Bytes
Contents
/** Create a union of all keys from a given type, even those exclusive to specific union members. Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member. @link https://stackoverflow.com/a/49402091 @example ``` import type {KeysOfUnion} from 'type-fest'; type A = { common: string; a: number; }; type B = { common: string; b: string; }; type C = { common: string; c: boolean; }; type Union = A | B | C; type CommonKeys = keyof Union; //=> 'common' type AllKeys = KeysOfUnion<Union>; //=> 'common' | 'a' | 'b' | 'c' ``` @category Object */ export type KeysOfUnion<ObjectType> = ObjectType extends unknown ? keyof ObjectType : never;
Version data entries
28 entries across 28 versions & 2 rubygems