Closed ytiq closed 2 years ago
@pmdartus @nolanlawson I confirm @ytiq isolated the problem correctly. It is not an issue related to vscode not loading the language server.
steps:
1 - create a lwc with the following code
import { LightningElement, api } from 'lwc';
export default class Test extends LightningElement {
@api set test1(value){}
get test2(){}
}
2 - verify it does work and no language server error is present 3 - change the lwc code to this one
import { LightningElement, api } from 'lwc';
export default class Test extends LightningElement {
@api set test1(value){}
@api get test2(){}
}
4 - verify that now you have the error from this issue 5 - conclude that in a class you can't decorate a getter and a setter with @api. You must choose one of them in the whole js file to decorate with @api. In other words, either all getters are decorated with @api, or all setters.
@AllanOricil weirdly enough, I tried adding my code as a jest test in lwc-compiler and it passes, so it might not be directly related to the latest version of lightning-language-server. I tried looking into dependencies of VS Code plugins itself and it seems that the latest lwc-language-server
is using "@lwc/compiler": "0.34.8"
which is 3 years old, so might be related to it
Summary
Short summary of what is going on or to provide context.
Steps To Reproduce:
Expected result
No Error from ESLint is shown
Actual result
@api get recordId and @api set recordId detected in class declaration. Only one of the two needs to be decorated with @api.
Additional information
Here is an example of LWC component and error producing code snippet down below https://webcomponents.dev/edit/4TuiynUFc1ccniIlgo2L
If at any place in the project you have
@api get
in the component then adding@api set
will give you an errorVS Code Version: 1.62
SFDX CLI Version: sfdx-cli/7.127.0 darwin-x64 node-v16.13.0
OS and version: macOs Catalina 10.15.7