Closed quantizor closed 1 day ago
https://swc.rs/docs/migrating-from-tsc#usedefineforclassfields
I actually tried that and didn't see a difference
@kdy1 thank you, you are right. In my case webpack cache did not properly bust with the .swcrc
change and I was seeing old results.
@kdy1 one point of confusion, the flag only works if set in swc config and if you do it in tsconfig.json
it is not picked up
Describe the bug
When working with ES6 classes and extending an existing class, but updating the type of a class variable, the variable is reinitialized and should not be.
Input code
"strictPropertyInitialization": false
is set intsconfig.json
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.3.101&code=H4sIAAAAAAAAA0utKMgvKlFIzkksLlYISC0qzs9zTE5OLS7OL1Ko5uVSUEiE8fISc1OtFIpLijLz0q1BMsn5eUBeaXJJfpEGsqQmRKOCQklGZrEeSEbBFqwbrKuWl6sWAHac7711AAAA&config=H4sIAAAAAAAAA2VQywqDQAy89ysk5xashR76Bb302vuyRtmyL5IIivjvXZ9Vektmksxk%2BlOWwYc1PLI%2BlamJihhp6xPCnRfVJgSki8iaTBQ4r6zwSFXKMm5YiTqQkkCcKKEGJ2KYeRBFNcp4D7nIi%2BtyC2wIjMvCAjnjTdXtzejgIiHzn6ZTvra4wkdBUp6rQG5%2FaPP4RmIT%2FOgnuSku%2BQ0O29gKklf2iTYi8U5hmgAXymYSXgIcQ5qfu8NvaH1kMw2GX%2BvmFNHwBf%2FIwMeMAQAA
SWC Info output
Expected behavior
Output:
^ Note the lack of variable redefinition in
PersonAccessor.constructor
Actual behavior
Output:
Note
_define_property(this, "json", void 0);
coming aftersuper(...args);
, this should not be there, there is no override to the value of the class variable only a type override.Version
1.9.2
Additional context
No response