Skip to content

Commit

Permalink
Merge pull request #10859 from dbellavista/master
Browse files Browse the repository at this point in the history
Restore  unpacked type and avoid distributive conditional types (#10767)
  • Loading branch information
vkarpov15 authored Oct 8, 2021
2 parents a553a39 + 036d178 commit e2aeac8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2487,11 +2487,11 @@ declare module 'mongoose' {
$eq?: T;
$gt?: T;
$gte?: T;
$in?: T[];
$in?: [T] extends AnyArray<any> ? Unpacked<T>[] : T[];
$lt?: T;
$lte?: T;
$ne?: T;
$nin?: T[];
$nin?: [T] extends AnyArray<any> ? Unpacked<T>[] : T[];
// Logical
$not?: T extends string ? QuerySelector<T> | RegExp : QuerySelector<T>;
// Element
Expand Down
11 changes: 10 additions & 1 deletion test/typescript/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,13 @@ function gh10757() {
type MyClassDocument = MyClass & Document;

const test: FilterQuery<MyClass> = { status: { $in: [MyEnum.VALUE1, MyEnum.VALUE2] } };
}
}

function gh10857() {
type MyUnion = 'VALUE1'|'VALUE2';
interface MyClass {
status: MyUnion;
}
type MyClassDocument = MyClass & Document;
const test: FilterQuery<MyClass> = { status: { $in: ['VALUE1', 'VALUE2'] } };
}

0 comments on commit e2aeac8

Please sign in to comment.