UNPKG

alistair

Version:
19 lines (17 loc) 647 B
type KeysWhereValueIsPropertyKey<T> = keyof { [Key in keyof T as T[Key] extends PropertyKey ? Key : never]: Key; }; /** * Matches a value based on a discriminator key * * @param value - The value to match * @param key - The discriminator key * @param options - The options to match against * @returns The result of the match */ declare function simple<T, K extends keyof T, Options extends { [Key in Extract<T[K], PropertyKey>]: (value: Extract<T, { [_ in K]: Key; }>) => any; }>(value: T, key: K, options: Options): ReturnType<Options[Extract<T[K], PropertyKey>]>; export { type KeysWhereValueIsPropertyKey, simple };