Skip to content

Enum reverse mapping is not generated #61488

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
npenin opened this issue Mar 26, 2025 · 2 comments
Closed

Enum reverse mapping is not generated #61488

npenin opened this issue Mar 26, 2025 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@npenin
Copy link

npenin commented Mar 26, 2025

πŸ”Ž Search Terms

enum reverse mapping

πŸ•— Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries about enums or reverse mapping

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.8.2#code/PQKhCgAIUhRA7ArgW0gJwKYAdMGcPwAuAlvAOaQBGpAhmgJ6QD2WGaNhTauAdFCMHAYAHli6FIBFJABCtBgHlW7TmnABvKJG2wAjohoAbSAF5IAchMnzAGi3aAyoTTEAxoT0HjZy1dv3IADkmD30jUwsAQms7bUdnN0Jg0K8I82iYgIAZDFxcABUACxp4NIAefzjIHLyikoU0T3CfMsyqgHFMDjY60p8APkq4zoxutF6Gpu8Lfra4gEF4ABM0gDJVoe0GtIAfHc3IAFlSRFw0gFoDgAVDU7SAagPDpiXEQyY0gFIDgBFiADc0sADvliMhcmkQNcmAB3NIAPV+ITSPAOAEVELkSEx4D9kT4APyo2JxABiXGQHDSAGIDgBVeAAa3gsL6FmE5nAAF9wEA

πŸ’» Code

export enum BinaryOperator
{
    Equal = '==',
    StrictEqual = '===',
    NotEqual = '!=',
    StrictNotEqual = '!==',
    LessThan = '<',
    LessThanOrEqual = '<=',
    GreaterThan = '>',
    GreaterThanOrEqual = '>=',
    And = '&&',
    Or = '||',
    Minus = '-',
    Plus = '+',
    Modulo = '%',
    Div = '/',
    Times = '*',
    Pow = '^',
    Dot = '.',
    QuestionDot = '?.',
    Format = '#',
    Unknown = 'x'
}

πŸ™ Actual behavior

Reverse mapping is not generated

πŸ™‚ Expected behavior

Reverse mapping should be generated as stated in https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings

Additional information about the issue

No response

@npenin npenin changed the title Enum reverse mapping is not applied Enum reverse mapping is not generated Mar 26, 2025
@npenin
Copy link
Author

npenin commented Mar 26, 2025

related issue ? #37282

@MartinJohns
Copy link
Contributor

MartinJohns commented Mar 26, 2025

This is working as intended. From the documentation you linked:

numeric enums members also get a reverse mapping from enum values to enum names.
[...]
Keep in mind that string enum members do not get a reverse mapping generated at all.

You don't have any numeric enum members. You only have string enum members.

@npenin npenin closed this as completed Mar 26, 2025
@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants