Skip to content

Untyped function calls #236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RyanCavanaugh opened this issue Jul 24, 2014 · 2 comments
Closed

Untyped function calls #236

RyanCavanaugh opened this issue Jul 24, 2014 · 2 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Spec Issues related to the TypeScript language specification

Comments

@RyanCavanaugh
Copy link
Member

Comments from @vladima

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:

class A { }
var x = A();

but this one - does not:

class A { }
var x = A(); // error
interface I { new (): I };
var c: I;
var y = c(); // OK
var c1: { new (): string };
var y1 = 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'.


@ahejlsberg :

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.

@RyanCavanaugh
Copy link
Member Author

Tried out on real world code and found no issues, unsurprisingly. Discussion in design meeting was uncontroversial. Move forward with implementation and spec change.

@sophiajt
Copy link
Contributor

Please assign to Anders for spec change when complete. Thanks!

@JsonFreeman JsonFreeman removed the Bug label Jul 25, 2014
@danquirk danquirk added the Bug label Jul 29, 2014
@RyanCavanaugh RyanCavanaugh added the Fixed A PR has been merged for this issue label Sep 11, 2014
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Spec Issues related to the TypeScript language specification
Projects
None yet
Development

No branches or pull requests

5 participants