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

feat: add custom omit utility type #2733

Merged
merged 6 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/curvy-ladybugs-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@contentful/f36-core": patch
---

feat: add custom omit utility type
12 changes: 12 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ export type PickUnion<UnionType, Keys> = Exclude<
UnionType,
Exclude<UnionType, Keys>
>;

/**
* Also known as homomorphic.
* Use this custom Omit utility type to preserve extended Record properties.
*
* Why? Using Omit on extended Records does not preserve the structure.
* - https://github.com/microsoft/TypeScript/issues/36981
* - https://github.com/microsoft/TypeScript/issues/54451
*/
export type MappedOmit<T, K extends keyof T> = {
[P in keyof T as P extends K ? never : P]: T[P];
};
Loading