Allow assignment of void returning functions to appropriate construct signature types #2310
Labels
Declined
The issue was declined as something which matches the TypeScript vision
Suggestion
An idea for TypeScript
Consider an existing JS constructor function
This is allowed in TypeScript due to a specific exception which allows
new
to be called on non-constructor functions only if they'revoid
returning. Now if you want to more strongly type this code, but without converting to full on classes yet, we do not allow you to do so in a fully typesafe manner:We require you to cast the constructor function to
any
orFunction
in order for it to be assignable to theFooConstructor
interface.Given that we've made an exception for
void
returning functions already in order to accommodate this pattern it doesn't seem crazy to make one more exception for them through the assignability relation in order to complete the desired scenario.See #2299 for another example from a customer.
The text was updated successfully, but these errors were encountered: