Skip to content

When there is only one member in the enum declaration, const enum A {x = 1}, the enum type obtained through the getTypeAtLocation interface is incorrect. #61917

Closed as not planned
@cy-hub-cloud

Description

@cy-hub-cloud

🔎 Search Terms

Enum

🕗 Version & Regression Information

  • This changed between versions ______ and _______
  • This changed in commit or PR _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

No response

💻 Code

const enum A {
x = 1
};

const enum B {
x = 1,
y = 1
};

🙁 Actual behavior

By using the getTypeAtLocation interface, the type of the enumeration is obtained. Enumeration B gets the enumeration type, while enumeration A gets the enumeration member type.

🙂 Expected behavior

Both Enum A and Enum B can get the enum type, not Enum A is the enum member type

Additional information about the issue

Although special logic bypass can be done through symbol.declarations, why is there a distinction in obtaining enumeration types when they are all enumeration types? Most of the time, obtaining types is to get the current type, and there is no need to directly provide the underlying type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    UnactionableThere isn't something we can do with this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions