Skip to content

Commit

Permalink
Fix: simplify MergeType constraints
Browse files Browse the repository at this point in the history
Fixes 16 errors in models.d.ts on Typescript 4.8 which is currently in
beta. Typescript 4.8 forbids assignment of an unconstrained type
parameter to one that disallows `null` or `undefined`:
microsoft/TypeScript#49489

The alternative fix is to constrain *lots* of types in models.d.ts to
`Record<string | number, any>` -- that is, to forbid `null | undefined`,
but I'm not sure it's worth the effort.
  • Loading branch information
sandersn committed Jun 22, 2022
1 parent 73156b5 commit 2a9ec91
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion types/utility.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ declare module 'mongoose' {
? T
: Omit<T, keyof U> & U;

type MergeType<A extends Record<number | string, any>, B extends Record<number | string, any>> = Omit<A, keyof B> & B;
type MergeType<A, B> = Omit<A, keyof B> & B;

}

0 comments on commit 2a9ec91

Please sign in to comment.