Skip to content

Contextual typing of object literal getters not working for return expressions #1611

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
JsonFreeman opened this issue Jan 7, 2015 · 2 comments
Labels
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript Too Complex An issue which adding support for may be too complex for the value it adds

Comments

@JsonFreeman
Copy link
Contributor

interface I {
    x: (p: number) => void;
}

var obj: I = {
    get x() {
        return q => { };
    }
}

q has type any, but should be number.

This is related to #1610

@JsonFreeman JsonFreeman added the Bug A bug in TypeScript label Jan 7, 2015
@JsonFreeman
Copy link
Contributor Author

We should probably do this for setters too. The parameter of the setter would acquire the contextual type if it has no type annotation, and a default initializer would also be contextually typed.

@sophiajt sophiajt added this to the TypeScript 2.0 milestone Jan 12, 2015
@mhegazy mhegazy added the Suggestion An idea for TypeScript label Apr 20, 2015
@mhegazy mhegazy modified the milestones: Suggestions, TypeScript 2.0 Apr 20, 2015
@mhegazy mhegazy removed the Bug A bug in TypeScript label Apr 20, 2015
@mhegazy mhegazy modified the milestone: Suggestions Apr 22, 2015
@mhegazy mhegazy added the In Discussion Not yet reached consensus label Jul 27, 2015
@RyanCavanaugh RyanCavanaugh added Too Complex An issue which adding support for may be too complex for the value it adds and removed In Discussion Not yet reached consensus labels Oct 5, 2015
@RyanCavanaugh
Copy link
Member

Punting based on complexity (due to how we might fix the type of q during overload resolution) and lack of feedback.

@RyanCavanaugh RyanCavanaugh added the Declined The issue was declined as something which matches the TypeScript vision label Oct 5, 2015
@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
Declined The issue was declined as something which matches the TypeScript vision Suggestion An idea for TypeScript Too Complex An issue which adding support for may be too complex for the value it adds
Projects
None yet
Development

No branches or pull requests

4 participants