Skip to content

Returned Enum value has its type needlessly widened #20254

@samijaber

Description

@samijaber

TypeScript Version: 2.7.0-dev.20171124

Code

enum Item { potato = "potato", cucumber = "cucumber" } // inferred type is `() => Item` const getPotato1 = () => Item.potato; // type assertion works const getPotato2: () => Item.potato = () => Item.potato;

Expected behavior:
Type of getPotato1 should be inferred as () => Item.potato.

Actual behavior:
Type of getPotato1 is "needlessly" widened to () => Item.

cc @OliverJAsh

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions