7

I've error

[js] Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

when I try to use @track in lightning web component

Here is the code

import { LightningElement , track } from 'lwc';

export default class Helloworld extends LightningElement {
    @track greeting = 'World';

    changeHandler(event) {
        this.greeting = event.target.value;
    }
}

enter image description here

I don't have a Jsonconfig file and tried to add manually but also didn't work enter image description here

  • can you post relevant code? I was able to use @track without any issues – Pranay Jaiswal Dec 24 '18 at 7:33
  • import { LightningElement , track } from 'lwc'; export default class Helloworld extends LightningElement { @track greeting = 'World'; changeHandler(event) { this.greeting = event.target.value; } } – Mayar Ahmed Dec 24 '18 at 7:35
  • can you edit the original question and put your code snippet there? its very hard to read from comments. – Pranay Jaiswal Dec 24 '18 at 7:36
  • Just tried your code, it worked charm, can you post screenshot of the error and some additional info if possible? and are you using VSCode and is your plugin on latest version? – Pranay Jaiswal Dec 24 '18 at 7:44
  • kindly check it – Mayar Ahmed Dec 24 '18 at 8:00
8

You have to enable that in compiler options.

Open jsconfig.json file and set that attribute experimentalDecorators inside compilerOptions as true. It will fix your issue.

enter image description here

enter image description here

  • I don't have a jsonconfig file so i tried to put it manual and add the code in your screenshot but also it didn't work .I've edited the question – Mayar Ahmed Dec 25 '18 at 8:15
  • 7
    In VSCode, Go to File => Preferences => Settings (or Control+comma) and it will open the User Settings file. Add "javascript.implicitProjectConfig.experimentalDecorators": true to the file and it should fix it. It did for me. – Mayar Ahmed Dec 25 '18 at 9:58
  • @MayarAhmed - if this answer fixed your problem, please check it as accepted – Itai Shmida Dec 26 '18 at 9:53
4

In your Visual Code Studio go to

File => Preferences => Settings

In the "Search Settings" Type "Experimental Decorators" and Enable its checkbox.

  • 1
    This is the only way I could get the error to go away even when "experimentalDecorators":true thing set correctly! Thank you! – freddy.smith May 30 at 12:58
1

{ "compilerOptions" :{ "experimentalDecorators":true, "baseUrl":".", "paths":{} } }

  • 1
    Can you add further informations in order to explain what your code done ?! – SF_user Feb 21 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.