Skip to content

Commit 9f40ebf

Browse files
committed
types: avoid WithLevel1NestedPaths drilling into non-records re: #15592 comments
1 parent 9c0b305 commit 9f40ebf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

types/utility.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ declare module 'mongoose' {
22
type IfAny<IFTYPE, THENTYPE, ELSETYPE = IFTYPE> = 0 extends (1 & IFTYPE) ? THENTYPE : ELSETYPE;
33
type IfUnknown<IFTYPE, THENTYPE> = unknown extends IFTYPE ? THENTYPE : IFTYPE;
44

5-
type WithLevel1NestedPaths<T, K extends keyof T = keyof T> = {
5+
type WithLevel1NestedPaths<T, K extends keyof T = keyof T> = IsItRecordAndNotAny<T> extends true ? {
66
[P in K | NestedPaths<Required<T>, K>]: P extends K
77
// Handle top-level paths
88
// First, drill into documents so we don't end up surfacing `$assertPopulated`, etc.
@@ -28,7 +28,7 @@ declare module 'mongoose' {
2828
: never
2929
: never
3030
: never;
31-
};
31+
} : T;
3232

3333
type HasStringIndex<T> =
3434
string extends Extract<keyof T, string> ? true : false;

0 commit comments

Comments
 (0)