I have the following piece of code
// Address and User are two classes, bothe of which have an id
type Q = Address | User
// This works just fine
async function c<EntityType extends Q>(ids: Q["id"][]) {
}
// This gives me the error described bellow
async function c<EntityType extends Q>(ids: EntityType["id"][]) {
}
When I in vscode hover over ids in the first function I get (parameter) ids: number[] (Which is expected as Q.id is a number) but if I hover over ids in the second function I get ids: EntityType["id"][]
This is leading to errors downstream... Why is this happening and how can I gix this?
Edit: Adding the aforementioned errors:
In the function I am using the line
const e = await em.findBy(entityClass, { id: In(ids) });
And typescript complains:
Argument of type '{ id: FindOperator<any>; }' is not assignable to parameter of type 'FindOptionsWhere<EntityType> | FindOptionsWhere<EntityType>[]'.
Types of property 'id' are incompatible.
Type 'FindOperator<any>' is not assignable to type 'FindOptionsWhereProperty<NonNullable<EntityType["id"]>>'
On {id: In(ids)} (entityClass is of type EntityType)