Replies: 1 comment 1 reply
-
| At first glance it looks like Mongoose's types may be wrong. Maybe replace this: // snippit from query.d.ts
find(
  filter: FilterQuery<DocType>,
  projection?: ProjectionType<DocType> | null,
  options?: QueryOptions<DocType> | null
): QueryWithHelpers<Array<DocType>, DocType, THelpers, RawDocType, 'find'>;with this? You're right that  | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am currently trying to fix typegoose/typegoose#870, but i got confused because of the 3 types mentioned in the title, for example:
Model.find({})'s return type is:(basically
Query<Document<>[], Document<>, {}, ActualRawObject, QueryOperation>)but doing a additional

.find(because it is possible and has the closest types to the query helpers) likeModel.find({}).find({})has actually the wrong typing for the suggestions in{}(for the second.find), because the second.finduses theDocTypeparameter of theQuery<>type, but that is set to aDocument<>, which makes it suggest function likepopulateas a value:in addition, fixing it in typegoose by replacing the current
mongoose.QueryWithHelpers<Document<>, Document<>>withmongoose.QueryWithHelpers<Document<>, RawClassType>actually breaks query helper functions which returnthis.find(and other functions) because those functions all return the genericDocTypein theQuery<>'sResultTypegeneric slot, instead of theResultTypegeneric. current code snippit:(notice the
QueryWithHelpers<DocType[], DocType>)where as the
Model's functions return aResultTypein theResultTypegeneric slot, snippit:(notice the
QueryWithHelpers<ResultDoc[], ResultDoc>)so my question is: am i doing things wrong, or are the mongoose types wrong?
mongoose 1bfcdf6 and 8.0.0 (even in 7.6.4)
Beta Was this translation helpful? Give feedback.
All reactions