Last active
September 17, 2024 06:07
-
-
Save bogdanovna/f887fb9c64a9b8366bfec57b1088fa46 to your computer and use it in GitHub Desktop.
type Omit with additional generic modifications
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 Prettify<T> = { | |
[K in keyof T]: T[K]; | |
} & {}; | |
export type Prefixed<T, P extends string> = { | |
[K in keyof T as K extends string ? `${P}${K}` : never]: T[K]; | |
}; | |
export type OmitStrict<T extends Record<string, any>, K extends keyof T> = Omit< | |
T, | |
K | |
>; | |
export type OmitReplace< | |
T extends Record<string, any>, | |
U extends Partial<{ | |
[key in keyof T]: any; | |
}>, | |
> = Omit<T, keyof U> & U; | |
export type AddOrReplace< | |
T extends Record<string, any>, | |
U extends Record<string, any>, | |
> = Omit<T, keyof U> & U; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment