You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In certain cases old compiler used to emit "Value of type is not callable. Did you mean to include 'new'" error when during analysis of call expression discover that type does not have call signatures and function being called was bound to constructor' symbol. This yields quite inconsistent results, for example this code will contain error:
classA{}varx=A();butthisone-doesnot:
classA{}varx=A();// errorinterfaceI{new(): I};varc: I;vary=c();// OKvarc1: {new(): string};vary1=c1();// OK
Per spec (4.12 Function calls) all these examples are correct and will result in untyped call. However I think having error here still has value because in most cases it will correctly signal about missing 'new'.
I think an untyped call should be permitted only if the type has no signatures at all (call or construct). Technically that's a breaking change, but I think it is a good one. The current behavior makes little sense and I highly doubt the change would break any real world code.
The text was updated successfully, but these errors were encountered:
Tried out on real world code and found no issues, unsurprisingly. Discussion in design meeting was uncontroversial. Move forward with implementation and spec change.
Comments from @vladima
Per spec (4.12 Function calls) all these examples are correct and will result in untyped call. However I think having error here still has value because in most cases it will correctly signal about missing 'new'.
@ahejlsberg :
The text was updated successfully, but these errors were encountered: