UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

27 lines 1.28 kB
export type KeysMatching<T, V> = { [K in keyof T]-?: T[K] extends V ? K : never; }[keyof T]; export type RemoveNulls<T> = Omit<T, KeysMatching<T, null>>; /** * MergeProps will merge keys from `U` over `T` except when the value of `T` is `null`. * * ```ts * MergeProps< * {foo: string, bar: string, baz: null}, * {foo: string, bar: number, baz: string} * > // { foo: string, bar: number, baz: null } * ``` */ export type MergeProps<T, U> = { [K in keyof T | keyof U]: K extends keyof T ? K extends keyof U ? T[K] extends null ? null : U[K] : T[K] : K extends keyof U ? U[K] : never; }; /** * Merges source props into target props, overwriting target props that are also defined on source * props. Callback will be merged in such a way that both callbacks will be called. `css` and * `style` props will be merged in such a way that source props have the final override. * * If `targetProps` has a `null` set, it will remove the prop from the `sourceProps`. This allows * passing of props from merged hooks to another without passing out to the final element props. */ export declare function mergeProps<const T extends object, const S extends object>(targetProps: T, sourceProps: S): RemoveNulls<MergeProps<T, S>>; //# sourceMappingURL=mergeProps.d.ts.map