Last active
April 19, 2023 07:52
-
-
Save bogdanovna/ea9b5458e9f29058d2d22be621983c48 to your computer and use it in GitHub Desktop.
Get value from some record having its key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type ValueByKeyType<T extends Record<string, any>, S extends keyof T> = T[S]; | |
/** | |
* Example of usage | |
**/ | |
import { ClientProxy } from '@nestjs/microservices'; | |
export type OverrideMicroClient<T extends Record<string, anny>> = Omit<ClientProxy, 'send' | 'emit'> & { | |
emit<K extends keyof T = keyof T>(pattern: K, ...args: Parameters<ValueByKeyType<T, K>>): ReturnType<ValueByKeyType<T, K>>; | |
send<K extends keyof T = keyof T>(pattern: K, ...args: Parameters<ValueByKeyType<T, K>>): ReturnType<ValueByKeyType<T, K>>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment