There is little info about NewableFunction except for the meeting notes in #27102 and the pr #27028.
As far as I understand the comments there, a NewableFunction should be "callable" with new Foo(...), right? Or do we have to stick with apply(...)/call(...)?
Example:
classFoo{}functiondoSomething(clazz: NewableFunction){newclazz();// This expression is not constructable.// Type 'NewableFunction' has no construct signatures}doSomething(Foo);// passes but would fail with "normal functions" aka. CallableFunctionQuestion about workaround:
If NewableFunction works as desired should we stick with new Function.prototype.bind.call(clazz, undefined); or should we define our own "ConstructableFunction" (a lot of people suggest this and even angular did it):
eg.
exportinterfaceConstructableFunctionextendsNewableFunction{new(...args: any[]): any}
There is little info about
NewableFunctionexcept for the meeting notes in #27102 and the pr #27028.As far as I understand the comments there, a
NewableFunctionshould be "callable" withnew Foo(...), right? Or do we have to stick withapply(...)/call(...)?Example:
Question about workaround:
If
NewableFunctionworks as desired should we stick withnew Function.prototype.bind.call(clazz, undefined);or should we define our own "ConstructableFunction" (a lot of people suggest this and even angular did it):eg.