Skip to content

Instantly share code, notes, and snippets.

@kirpalmakanga
Last active May 28, 2025 14:54
Show Gist options
  • Save kirpalmakanga/33d2e8891d9b67ca6740ad6f999e4f67 to your computer and use it in GitHub Desktop.
Save kirpalmakanga/33d2e8891d9b67ca6740ad6f999e4f67 to your computer and use it in GitHub Desktop.
Type-safe omit function
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