I have a Typescript class with a private constructor:
class Foo {
private constructor(private x: number) {}
}
For testing purposes I would like to call this constructor from outside the class (please don't argue this point). Typescript provides an escape method for accessing private fields, like foo["x"]
(see this other question) but I can't figure out the syntax for calling the constructor. It should be something like this right?
const f = new Foo["constructor"](5);
But that doesn't work. What's the correct syntax?