Skip to content
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

Function parameter only gets inferentially typed if a type parameter coincides with it #1449

Closed
JsonFreeman opened this issue Dec 11, 2014 · 5 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@JsonFreeman
Copy link
Contributor

In inferential typing, we only fix a type parameter and contextually type a function parameter if the inference walker hits the type parameter and the function parameter at the same time (foo2 below). Ideally, we would also want this to work if the walker hits the type parameter before hitting the function parameter in the argument (foo1). At that point, we may fix the type parameter, and then keep drilling into it, then use the relevant part when we hit the function parameter in the argument.

declare function foo1<T>(a: T, b: T);
foo1((s: string) => { }, x => { x.blah }); // x is any, contextual typing did not take place

declare function foo2<T>(a: (x: T) => void, b: (x: T) => void);
foo2((s: string) => { }, x => { x.blah }); // x is string, contextual typing did take place
@JsonFreeman JsonFreeman added Bug A bug in TypeScript Suggestion An idea for TypeScript Spec Issues related to the TypeScript language specification labels Dec 11, 2014
@JsonFreeman
Copy link
Contributor Author

Note that this may make it hard to be smarter about determining whether a given expression is context sensitive.

@mhegazy mhegazy added this to the TypeScript 1.6 milestone Dec 15, 2014
@mhegazy mhegazy removed the Bug A bug in TypeScript label Apr 20, 2015
@mhegazy mhegazy modified the milestones: Suggestions, TypeScript 1.6 Apr 20, 2015
@JsonFreeman JsonFreeman added the Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. label Jul 14, 2015
@mhegazy mhegazy added Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it and removed Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Spec Issues related to the TypeScript language specification Suggestion An idea for TypeScript labels Jul 27, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Jul 27, 2015

Since we have not gotten any concrete feedback on this, i am inclined to leave the current rule the way it is.

@mhegazy mhegazy closed this as completed Jul 27, 2015
@JsonFreeman JsonFreeman added Bug A bug in TypeScript and removed Won't Fix The severity and priority of this issue do not warrant the time or complexity needed to fix it labels Jul 31, 2015
@JsonFreeman JsonFreeman reopened this Jul 31, 2015
@JsonFreeman
Copy link
Contributor Author

I am not so sure that we haven't gotten feedback on this. We get a lot of nebulous type argument inference bug reports, and some of them may in fact be related to this. We can sit on it, but I don't think it matches user expectations.

@JsonFreeman JsonFreeman removed their assignment Jul 31, 2015
@RyanCavanaugh RyanCavanaugh added Needs More Info The issue still hasn't been fully clarified and removed Bug A bug in TypeScript labels Aug 2, 2016
@RyanCavanaugh
Copy link
Member

Invoking the 1-year clause on this one

@JsonFreeman
Copy link
Contributor Author

Reading this again, over a year later, I have to say I'm not surprised that nobody cared!

@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
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

3 participants