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
useDefineForClassFields: false always works in tsc, no matter what the target is.
However, if this option is missing, the tsc result will be different when the target changes.
The behavior of the Native class field is [[Define]].
The behavior of swc and tsc is not identical, and the JS and TS outputs of swc are not identical.
We expect useDefineForClassFields: false to always work.
We expect the same results from JS and TS.
x can be either [[Define]] or [[Set]].
If we choose [[Set]], then we keep the same behavior as TypeScript.
If we choose [[Define]], then we get consistency with our None option, since Native means [[Define]].
**BREAKING CHANGE:**
IMPORTANT NOTE: Users of decorators are recommended to configure `"useDefineForClassFields": false` to ensure that your code is properly transpiled.
**Related issue:**
- Closes#6985.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Describe the bug
result from TypeScript:
useDefineForClassFields: false
always works in tsc, no matter what the target is.However, if this option is missing, the tsc result will be different when the target changes.
The behavior of the
Native
class field is[[Define]]
.The behavior of swc and tsc is not identical, and the JS and TS outputs of swc are not identical.
Ref: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier
Input code
Config
No response
Playground link
No response
Expected behavior
useDefineForClassFields: false
to always work.x can be either
[[Define]]
or[[Set]]
.If we choose
[[Set]]
, then we keep the same behavior as TypeScript.If we choose
[[Define]]
, then we get consistency with ourNone
option, sinceNative
means[[Define]]
.Actual behavior
useDefineForClassFields: false
does not work for ES2022.useDefineForClassFields: false
are different for TS and JS.useDefineForClassFields: None
are different for TS and JS.Version
1.3.36
Additional context
Output 1:
Native
class fieldOutput 2:
[[Set]]
Output 3:
[[Define]]
from TypeScriptOutput 4:
[[Define]]
from swcThe text was updated successfully, but these errors were encountered: