Home > Net >  replaceAll function is being marked as...?
replaceAll function is being marked as...?

Time:12-15

The code you are seeing technically works. But VS Code, shows me an underline under the replaceAll function. I would like to know why, and what I could do to avoid this happening again.

renderTemplateText(str) {
    var parser = new DOMParser();
    var doc = parser.parseFromString(str, "text/html");
    var xRepeat = doc.querySelectorAll('[x-repeat]');
    var divarray = doc.querySelectorAll('[is^="x-"]');
    var divarraylength = divarray.length;


    for (var i = 0; i < divarraylength; i  ) {                                                           
            var dataAttribute = divarray[i].getAttribute('data-link');                                                  
            console.log(divarray[i]);                                                    
            if (dataAttribute !== null) {                                           
                dataAttribute = dataAttribute.replaceAll("props", this.propsname);
            }                                                              
            console.log(dataAttribute );
    }
}

CodePudding user response:

This can be fixed by changing your jsconfig.json target to es2021, since String.replaceAll is a ES2021 feature.

Example:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es2021",
        "jsx": "preserve",
        "strictFunctionTypes": true
    },
    "exclude": [
        "node_modules",
        "**/node_modules/*"
    ],
    "include": [
        "**/**/*"
    ]
}

CodePudding user response:

You can honestly just ignore this. It's just a VS Code thing. I am assuming it works? I made the not given value props myself, and it worked fine.

If you really want to fix this though, you have to change your jsconfig.json target to "es2021".

  • Related