I'm trying to add typings for a library which has a new
able function, but finding it really difficult to do.
With simply:
export default function Api<T>(opts?: Settings): Api<T>;
I get "Only a void function can be called with the 'new' keyword". I'm aware of the new
keyword being valid in the declaration file, such as:
export default interface Api {
new<T=any>(opts?: Settings): Api<T>
}
That is just exporting a type, as the compiler says: "only refers to a type, but is being used as a value here".
I can't use a class here, since the API can be extended by plug-ins from other files, and type declaration merging doesn't work on classes (and I want the methods added by the other files to be able to typed by their own typing files as well).
I'm at a loss - any ideas?