Looking for advice: I am new to TypeScript and have classes defined like the ones below:
export declare class SampleOne extends Setting {
getValue(): Promise<boolean>;
setValue(value: boolean): Promise<void>;
}
And
export declare class SampleTwo extends Setting {
getValue(): Promise<boolean>;
setValue(value: boolean): Promise<void>;
}
Now I want a helper function where I can pass either SampleOne or SampleTwo as follows:
async function getObj(title: string, categories: string, cname: Setting) {
let obj = await et.findSetting(title,categories) as cname;// I want to be able to pass either **SammpleOne** or **SampleTwo** class.
return obj;
}
The function call would be:
getObj(title, categories, SampleOne)
getObj(title, categories, SampleTwo)
I am struggling to create this helper function. What should it look like in TypeScript?
Thank you in advance.