-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Property decorator not working anymore #44449
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
Comments
The playground emits the same code when you turn the flag |
Indeed! And it causes the same behaviour as in my repo. So is this expected behaviour? I suspect not, given that it makes this property decorator useless |
No idea. Most likely unintended, but working as it should. The class fields feature is fairly new, and the decorator support is based on a deprecated proposal. Tho the decorator isn't even relevant here - it's working perfectly fine and as it should. What doesn't work as you expect is the |
I have the same problem, upgrading TypeScript from 4.2 to 4.3 broke my Vue components which uses import Vue from "vue"
import { Component, Prop } from "vue-property-decorator"
@Component
export default class Test extends Vue {
@Prop(Number) readonly id!: number
readonly idStr: string = this.id.toString()
}
Setting |
Are you targetting |
Ok all that makes sense. Is there a recommended way or alternative to these kinds of property decorators? They do provide a nice way to reuse getter / setter code. |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow. |
Bug Report
Using a property decorator doesn't seem to work anymore. In the playground it does work however (see links below).
🔎 Search Terms
typescript 4.3 property decorator
🕗 Version & Regression Information
⏯ Playground Link
Interestingly this bug doesn't occur in the playground. Maybe it is linked to modules somehow? This is the link to the repo.
Only the index.ts and the C1.ts are relevant.
💻 Code
The difference seems to be that for this TS code
In the playground sth like this JS is generated:
while in my example project this JS is generated:
🙁 Actual behavior
The code behaves as if the decorator is never executed (it is however).
🙂 Expected behavior
The simple field should have been replaced by the property with getter/setter.
The text was updated successfully, but these errors were encountered: