I'm writing types declaration for a framework, for a function, it has a parameter whose type is object, but I want to describe it using interface in the declaration type like this:
interface Options{
template: string | Selector | AST;
config (data: object): void;
}
interface Regular_Static {
new (options: Options): Regular_Instance;
// todo
}
declare var Regular: Regular_Static;
export = Regular
But when I write like this in my application:
class HelloRegular extends Regular {
constructor(options: object){
super(options);
}
}
it shows that type object can't be assignment to type Options. So how to do with it?
supplement: The Options type declaration can't be got in application unless we declare it in our application. I mean to let the Options do like an object.
Regular_Staticexpects an object withtemplateandconfigwhy would the compiler allow you to call the constructor (assuper(options)) with an object that may not have those properties ?options: objecttooptions: Options?Optionsin application