Skip to content

Commit

Permalink
feat: add custom omit utility type (#2733)
Browse files Browse the repository at this point in the history
  • Loading branch information
cf-remylenoir committed Apr 29, 2024
1 parent 6f5c6b1 commit 80c7f67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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];
};

0 comments on commit 80c7f67

Please sign in to comment.