You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We can quickly address your report if:// - The code sample is short. Nearly all TypeScript bugs can be demonstrated in 20-30 lines of code!// - It doesn't use external libraries. These are often issues with the type definitions rather than TypeScript bugs.// - The incorrectness of the behavior is readily apparent from reading the sample.// Reports are slower to investigate if:// - We have to pare too much extraneous code.// - We have to clone a large repo and validate that the problem isn't elsewhere.// - The sample is confusing or doesn't clearly demonstrate what's wrong.
🙁 Actual behavior
When you iterate through enum keys you find that the keys are logged then the values of each key are logged as well when using Object.keys(). When you use Object.entries() you find that the keys and values on the original object are printed and then the values are printed as the keys and the keys printed as values. This all happens during the same iteration.
🙂 Expected behavior
I expected the keys and values to be logged when using Object.entries() . When I use Object.keys() i expect the keys to be logged not the values at all
The text was updated successfully, but these errors were encountered:
Working as intended. Number-valued enums contain bidirectional mappings so that, e.g. Foo[Foo.Bad] is "Bad". This is so you can more easily look up enum values in the debugger. If you don't want the reverse mappings you could try a string-valued enum.
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
https://www.typescriptlang.org/play?#code/KYOwrgtgBAYg9nKBvAsAKCpqBxBATAGnSygCEBDQ9AX3XQGM4QBnOAG2ADoBzAJzjAAHABQAiAKLhoAdwCWAFwAWUAPIAjAFbB68qAGtgAT2aiAlOnVadnA8eHw4pzgDM4vceXqLhtgLwA+KEYWdi42OG5hJFtqU3M0YNYOHn4hSTxheIYmJK4+AREJKSg5JVVNbV0AN3I2MGATeMtKzhq6hvsEJ1d3T282+oCgnNDOcMikAeBYrISR5Py0kAzZxNHFwslIEoVlZp0oUHleWQazCwrrI5OOh263Dy9hYQBtWwIoKYBdUyHskOS4yi70+tXqMzocwBeVSgnSmXQQA
💻 Code
🙁 Actual behavior
When you iterate through enum keys you find that the keys are logged then the values of each key are logged as well when using
Object.keys()
. When you useObject.entries()
you find that the keys and values on the original object are printed and then the values are printed as the keys and the keys printed as values. This all happens during the same iteration.🙂 Expected behavior
I expected the keys and values to be logged when using
Object.entries()
. When I useObject.keys()
i expect the keys to be logged not the values at allThe text was updated successfully, but these errors were encountered: