Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mapped types for account data content #4590

Merged
merged 12 commits into from
Dec 19, 2024
Prev Previous commit
Next Next commit
Iterate
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
  • Loading branch information
t3chguy committed Dec 19, 2024
commit d28bf645addbbfb9238b403bd1c01572e13d0e24
5 changes: 4 additions & 1 deletion src/@types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
export type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
export type Writeable<T> = { -readonly [P in keyof T]: T[P] };

// Based on https://stackoverflow.com/a/57862073
/**
* Returns a union type of the keys of the input object type whose values are assignable to the given type.
* Based on https://stackoverflow.com/a/57862073
*/
export type Assignable<Obj, Item> = {
[Key in keyof Obj]: Obj[Key] extends Item ? Key : never;
}[keyof Obj];
Loading