-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Object.values on an enum with template literal values #3329
Comments
TypeScript's rule for this is the backward mapping is only omitted if the initializer is a string literal, which is also the rule that esbuild implements. I think the issue here is that esbuild doesn't necessarily inline constants in the exact same situations that TypeScript does, which affects whether the initializer is a string or not. The general solution here isn't for esbuild to replicate TypeScript's behavior exactly because that's impossible (TypeScript's behavior for this may involve type information, for example with the inlining of I think in this case esbuild could potentially consider a template literal initializer to be the same as a string literal. Then esbuild would mostly match TypeScript's behavior (except in the case where TypeScript can't inline the string, but then TypeScript emits a compile error so esbuild's behavior doesn't really matter in that case). |
My workaround for is migrating back to @evanw if you do fix this let me know but at least this issue is here for others who encounter the behaviour. Closing for now. |
I plan to apply the fix that I described above. |
Repro: https://github.com/Hacksore/test-ts-objects-literals
This only happens with
esbuild
and when you use template literal values.I can't repro on tsplayground
repro code
expected
actual
The text was updated successfully, but these errors were encountered: