I have a method in a class whose call signature is:
async where(
prop: K & string,
value: PropType<T, K> | [IComparisonOperator, PropType<T, K>],
options: IDexieListOptions<T> = {}
) { ...}
The class's definition defines both T and K as:
class MyClass<T extends Model, K extends keyof T> { ... }
and the PropType type is simply this:
type PropType<TObj, TProp extends keyof TObj> = TObj[TProp]
In another method of the same class I try to use where like so:
async since(datetime: epoch) {
return this.where("lastUpdated", [">", datetime]);
}
the lastUpdated property is a valid property of Model which <T> extends and of course it is also a "string" so it would appear to meet the signature for where() but instead I get this errror:
'"lastUpdated"' is assignable to the constraint of type 'K', but 'K' could be instantiated with a different subtype of constraint 'string | number | symbol'.
Does anyone know how to get around this?
The Model class -- which I should have included to start with -- is defined as such:
export class Model {
public id?: string;
public lastUpdated?: number;
public createdAt?: number;
}
I did wonder if the fact that lastUpdated is optional was a contributing factor but even making it required seems to make no difference.
