I am facing an issue with a typescript function that involves a generic class called "Model" with a static method called "build". Typescript is not recognizing the static methods within the class and displaying errors, although the compiled JavaScript works fine:
export function dataToInstance(model: Model, data: any) {
if (!data) {
return data;
}
const include = generateIncludeRecurse(model);
const instance = model.build(data, { isNewRecord: false, raw: false, include });
restoreTimestamps(data, instance);
return instance;
}
Error: https://i.sstatic.net/rCN1J.png
I am looking for a solution to make typescript recognize the static methods. I have already attempted using "typeof", but it resulted in errors due to model being an abstract class.