When using the following construct Typescript fails to infer the correct type and match it with a partial of the same object. I assume this is not a bug and I am missing something. Can anybody tell me what I am missing?
class Repository<DTO extends {
id: string
}> {
findOne(what: Partial<DTO>) {
}
get(id: DTO["id"]) {
this.findOne({ id }); // TS2345: Argument of type '{ id: DTO["id"]; }' is not assignable to parameter of type 'Partial '.
this.findOne({ id } as Partial<DTO>); // manual casting works
}
}
If anybody has a better suggestion for the title please go ahead, this is almost impossible to search.