You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceIModel{id: string;}typeQuery<T>={[PinkeyofT]?: T[P]}exportclassBase<TextendsIModel>{publicfind(query: Query<T>): void{// Forward the query to databaseconsole.log(query);}publicfindOneById(id: string): void{this.find({ id });}}
Expected behavior:
It's expected to allow to execute the find with the properties defined on IModel as base of any other model;
Actual behavior:
It shows an error:
Argument of type '{ id: string; }' is not assignable to parameter of type 'Query<T>'.ts(2345)
TypeScript Version: 3.8.3
Search Terms:
[P in keyof T]?: T[P]typescript generic extends in keyoftypescript generic extends T[P]typescript mongo collection genericCode
Expected behavior:
It's expected to allow to execute the find with the properties defined on
IModelas base of any other model;Actual behavior:
It shows an error:
Playground Link:
https://typescript-play.js.org/#code/JYOwLgpgTgZghgYwgAgJIFkD2ATCAbZAbwCgBIYbALmQGcwpQBzAbmIF9jiwBPABxQCKAV2jcAPABUAfMgC8RMgG0ACslDIA1hG6YYyCQF0A-NQkqD7ThAAevTFDDIEeODRrIAQq4iTkNyCDY7hg4+DIkpLxCAEZ4wAjIMKDYABQAjiJQ3NTCopJSAJTUAG6YFAqkpAD0VcgAYvYA7nBQ2MhgABYoGaLtmMjYcGBw0d5kpAiYIDSYeBAAdHiYjOmZ3AWspBxkUbHxickA8iAQHtyoqRTUdAwgjEXIpeURpJ3ANPNJgSmEam1sGzIHA4QA
Related Issues:
Didn't find any related issue