Giter Site home page Giter Site logo

@api get recordId and @api set recordId detected in class declaration. Only one of the two needs to be decorated with @api. about lightning-language-server HOT 4 CLOSED

forcedotcom avatar forcedotcom commented on June 15, 2024
@api get recordId and @api set recordId detected in class declaration. Only one of the two needs to be decorated with @api.

from lightning-language-server.

Comments (4)

ytiq avatar ytiq commented on June 15, 2024 1

@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

from lightning-language-server.

randi274 avatar randi274 commented on June 15, 2024 1

Thanks for logging this! Since we're tracking it over in the extensions repo with #3704, I'll close this issue in favor of that one for now.

from lightning-language-server.

AllanOricil avatar AllanOricil commented on June 15, 2024

@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.

from lightning-language-server.

AllanOricil avatar AllanOricil commented on June 15, 2024

salesforce/lwc#2406
salesforce/eslint-config-lwc#66

from lightning-language-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.