Skip to content

Commit f6545db

Browse files
committed
types: remove incorrect callback type signature for projection
1 parent 7bb3864 commit f6545db

File tree

3 files changed

+1
-16
lines changed

3 files changed

+1
-16
lines changed

test/types/models.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,6 @@ function find() {
225225
Project.find({}, { name: 1 });
226226
Project.find({}, { name: 0 });
227227

228-
// filter + callback
229-
Project.find({}, (error: CallbackError, result: IProject[]) => console.log(error, result));
230-
Project.find({ name: 'Hello' }, (error: CallbackError, result: IProject[]) => console.log(error, result));
231-
232228
// filter + projection + options
233229
Project.find({}, undefined, { limit: 5 });
234230
Project.find({}, null, { limit: 5 });

test/types/queries.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ Test.find({ name: ['Test1', 'Test2'] }).exec();
9797
// Implicit `$in` for regex string
9898
Test.find({ name: [/Test1/, /Test2/] });
9999

100-
Test.find({ name: 'test' }, (err: Error | null, docs: ITest[]) => {
101-
console.log(!!err, docs[0].age);
102-
});
103-
104-
Test.findOne({ name: 'test' }, (err: Error | null, doc: ITest | null) => {
105-
if (doc != null) {
106-
console.log(!!err, doc.age);
107-
}
108-
});
109-
110100
Test.find({ name: { $gte: 'Test' } }, null, { collation: { locale: 'en-us' } }).exec().
111101
then((res: Array<ITest>) => console.log(res[0].name));
112102

types/index.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,8 @@ declare module 'mongoose' {
686686
type _IDType = { _id?: boolean | 1 | 0 };
687687
type InclusionProjection<T> = IsItRecordAndNotAny<T> extends true ? Projector<WithLevel1NestedPaths<T>, true | 1> & _IDType : AnyObject;
688688
type ExclusionProjection<T> = IsItRecordAndNotAny<T> extends true ? Projector<WithLevel1NestedPaths<T>, false | 0> & _IDType : AnyObject;
689-
type ProjectionUnion<T> = InclusionProjection<T> | ExclusionProjection<T>;
690689

691-
export type ProjectionType<T> = (ProjectionUnion<T> & AnyObject) | string | ((...args: any) => any);
690+
export type ProjectionType<T> = (InclusionProjection<T> & AnyObject) | (ExclusionProjection<T> & AnyObject) | string;
692691
export type SortValues = SortOrder;
693692

694693
export type SortOrder = -1 | 1 | 'asc' | 'ascending' | 'desc' | 'descending';

0 commit comments

Comments
 (0)