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

Fix lowering standard decorators on a class with inheritance causing field initializers before super call with useDefineForClassFields: false #4092

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

furkanevran
Copy link

@furkanevran furkanevran commented Feb 21, 2025

Allow omitting the field initializers if the class have a decorator and the field doesn't since esbuild doesn't initialize it with extra initializers and only set it to it's default value when useDefineForClassFields is false

Fixes #4087

…field initializers before super call

Allow omitting the field initializer if it doesn't have a decorator since we don't initialize it with extra initializers and only set it to it's default value
@furkanevran furkanevran changed the title Fix lowering standard decorators on a class with inheritance causing field initializers before super call Fix lowering standard decorators on a class with inheritance causing field initializers before super call with useDefineForClassFields: false Feb 21, 2025
@furkanevran
Copy link
Author

furkanevran commented Feb 21, 2025

I could also alternatively replace the condition on:

if result.lowerAllInstanceFields && class.ExtendsOrNil.Data != nil {
result.shimSuperCtorCalls = true
}

to

class.ShouldLowerStandardDecorators || (result.lowerAllInstanceFields && class.ExtendsOrNil.Data != nil)

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

Successfully merging this pull request may close these issues.

Private field incorrectly initialized before the super call
1 participant