@rx-angular/cdk
Version:
@rx-angular/cdk is a Component Development Kit for ergonomic and highly performant angular applications. It helps to to build Large scale applications, UI libs, state management, rendering systems and much more. Furthermore the unique way of mixing reacti
34 lines (33 loc) • 863 B
TypeScript
export declare function isKeyOf<O>(k: unknown): k is keyof O;
export declare function isObjectGuard(obj: unknown): obj is object;
export declare function isDefined(val: unknown): val is NonNullable<any>;
/**
* @description
* Allows to pass only keys which value is of specific type.
*
* @example
*
* interface Creature {
* id: number;
* type: string;
* name: string;
* }
*
* const cat = {id: 1, type: 'cat', name: 'Fluffy'};
*
* function updateCreature<T>(creature: T, key: OnlyKeysOfSpecificType<T, string>, value: string) {
* // update logic
* }
*
* // Valid key
* updateCreature(cat, 'name', 'Luna');
*
* // Invalid key
* updateCreature(cat, 'id', 3);
*
* @docsPage OnlyKeysOfSpecificType
* @docsCategory interfaces
*/
export type OnlyKeysOfSpecificType<T, S> = {
[Key in keyof T]: S extends T[Key] ? Key : never;
}[keyof T];