Skip to content

keyof Enum #14106

@sebdoucet

Description

@sebdoucet

Hi,

I ve seen a post over this particular suggestion, but I did not understant why (in typescript, not in js)

why this kind of behavior is not expected on keyof over enum:

enum Kind {
   none,
   bob
}

interface SomeJsonData {
    kind: keyof Kind;
    insteadOfKind: "none" | "bob";
}

Just saying that because it was my first reflex trying keyof over enums out of Partial or Readonly's.
Enum are not part of ecmascript (as I know) so keyof applyed to typescript should have a typescript specific behavior.

I also did not expect keyof returns number values, but if it does, still make more sense than current behavior.

Cheers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions