Last active
May 28, 2025 14:54
-
-
Save kirpalmakanga/33d2e8891d9b67ca6740ad6f999e4f67 to your computer and use it in GitHub Desktop.
Type-safe omit function
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 function omit<T extends object, K extends keyof T>( | |
base: T, | |
...keys: K[] | |
): Omit<T, K> { | |
if (keys.length) { | |
const result = { ...base }; | |
for (const key of keys) delete result[key]; | |
return result; | |
} | |
return base; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment