Skip to content
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

Broken decorators with target >= es2022 #2992

Closed
jpzwarte opened this issue Mar 15, 2023 · 1 comment
Closed

Broken decorators with target >= es2022 #2992

jpzwarte opened this issue Mar 15, 2023 · 1 comment

Comments

@jpzwarte
Copy link

See https://gist.github.com/jpzwarte/f0a698c0dc15f2242128d27a13a47d2d and notice line 50 in the es2022.log which is causing the bug.

Similar to #2629

This happens with >= 0.16.

@evanw
Copy link
Owner

evanw commented Mar 15, 2023

There's a note on esbuild's website about this: https://esbuild.github.io/content-types/#tsconfig-json

Note: TypeScript silently shipped a breaking change in version 4.3.2 where if the useDefineForClassFields option is not specified, it defaults to true if you specify target: "ESNext" (and later on also target: "ES2022" or newer). Before version 4.3.2, the useDefineForClassFields option always defaulted to false. The latest version of esbuild has been updated to reflect the behavior of TypeScript version 4.3.2. If you need the old behavior, make sure to specify useDefineForClassFields: false in addition to target: "ESNext". See TypeScript PR #42663 for more information.

I agree that this behavior is unfortunate and confusing. But I believe esbuild's behavior should match the behavior of the TypeScript compiler here, so in that sense esbuild is "working as intended" because that's how the TypeScript team has decided it should work. The only way to know for sure whether this is a bug with esbuild or not would be for you to provide a self-contained way to reproduce the issue, which was not provided here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants