export interface CommonArgs { 'aria-label'?: string; 'data-test-subj'?: string; } /** * Wraps Object.keys with proper typescript definition of the resulting array */ export function keysOf(obj: T): K[] { return Object.keys(obj) as K[]; } /** * Returns member keys in U not present in T set to never * T = { 'one', 'two', 'three' } * U = { 'three', 'four', 'five' } * returns { 'four': never, 'five': never } */ export type DisambiguateSet = { [P in Exclude]?: never; }; /** * Allow either T or U, preventing any additional keys of the other type from being present */ export type ExclusiveUnion = T | U extends object // if there are any shared keys between T and U ? (DisambiguateSet & U) | (DisambiguateSet & T) // otherwise the TS union is already unique : T | U; /* https://github.com/Microsoft/TypeScript/issues/28339 Problem: Pick and Omit do not distribute over union types, which manifests when optional values become required after a Pick or Omit operation. These Distributive forms correctly operate on union types, preserving optionality. */ type UnionKeys = T extends any ? keyof T : never; export type DistributivePick> = T extends any ? Pick> : never; export type DistributiveOmit> = T extends any ? Omit> : never;