-
Notifications
You must be signed in to change notification settings - Fork 398
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
Decorators don't work in TypeScript after following Developer Preview guide #5087
Comments
Thanks for opening the issue! By any chance could you share a Git repo / Gist / TypeScript playground / etc to help repro? |
I used the code snippet I wrote above and the TS guide to create this repro: https://github.com/jparta/LWC_decorator_repro You'll still have to follow the TS guide to get your environment to the state that I have it in. TS guide again: https://developer.salesforce.com/docs/platform/lwc/guide/ts.html |
@nolanlawson |
This looks like you may have |
Did you check the repro I linked to? The guide states
From repro:
Extended
|
Looks like you're using the VS Code extension, which is known to be outdated, so you must use |
@wjhsf The TS guide says
If I use this
But upon opening the page which includes the component, I get this error, with no errors in the console:
I've updated the repro to include exposing the component, a text for when it succesfully loads, and setting I remember that I tried setting My previous config (built according to a previuous version of the TS guide) had
Which resulted in the error
|
I originally closed this issue because it was already reported in #2078, but after reading through that issue again, I think it's become a bit cluttered. I'll leave this one open as it's more narrowly scoped to just the incompatibility with the VS Code extension. Sorry for the misdirection, there's more going on here than I remembered! To summarize the findings in the other issue, the LWC compiler requires that decorator syntax ( LWC only began supporting export default class extends LightningElement {
// @ts-expect-error The Salesforce VS Code extension doesn't like modern decorators
@api someProp?: string;
} This issue will be resolved when the VS Code extension can be updated to use the latest version of LWC, tracked at forcedotcom/lightning-language-server#602. It also may be resolved if we can restore support for experimental decorators (#5084 (comment)), but that might not be possible. |
I've submitted changes to document this issue in the TypeScript Dev Preview guide. The changes should be live next week. |
Description
Steps to Reproduce
I followed this guide: https://developer.salesforce.com/docs/platform/lwc/guide/ts.html
Expected Results
Typescript accepts the decorator @api
Actual Results
In VS Code, I get the following TypeScript error:
This prevents deploying to org.
Version
The text was updated successfully, but these errors were encountered: