Skip to content

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

Closed

Description

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

Activity

  1. JsonFreeman commented on Jan 7, 2015

    @JsonFreeman
    ContributorAuthor

    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.

  2. modified the milestones: , TypeScript 2.0 on Apr 20, 2015
  3. modified the milestone: on Apr 22, 2015
  4. added
    Too ComplexAn issue which adding support for may be too complex for the value it adds
    and removed on Oct 5, 2015
  5. RyanCavanaugh commented on Oct 5, 2015

    @RyanCavanaugh
    Member

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

  6. locked and limited conversation to collaborators on Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptToo ComplexAn issue which adding support for may be too complex for the value it adds

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions