-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Description
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:
class Foo {}
function doSomething(clazz: NewableFunction) {
new clazz();
// 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.
export interface ConstructableFunction extends NewableFunction {
new(...args: any[]): any
}Metadata
Metadata
Assignees
Labels
No labels