I have a TypeScript class representing a JavaScript class, but the TypeScript declaration is missing the constructor parameters that are present in the JavaScript class. Is there a way to work around this limitation in TypeScript and still create an object by passing in the necessary parameters?
This scenario arises because I need to create special test mock-ups by bypassing restrictions in a library. I am open to any creative solutions or hacks.
Below is the JavaScript class hidden within a third-party library:
class InnerClass {
constructor(param1, param2, param3) {
}
}
And here is the TypeScript declaration exposed by the library:
class InnerClass {
// no constructor
}
The goal is to achieve something like this:
const a: InnerClass = new InnerClass(param1, param2, param3);
In essence, creating an object of the right TypeScript type with the correct constructor parameters, despite the limitations imposed by the TypeScript declaration. Is such workaround possible in TypeScript?