ioBroker / ioBroker.javascript

Script engine for JavaScript and Blockly
MIT License
322 stars 120 forks source link

String.replaceAll is not recognized as valid command in TypeScript #1485

Closed neopholus closed 5 months ago

neopholus commented 5 months ago

Describe the bug
String.replaceAll is not recognized as valid command in TypeScript Editor but compiles and works correctly. If you use it, replaceAll has a red line below it and the following error is shown: Property 'replaceAll' does not exist on type 'string'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later.(2550)

But codes compiles and executes correctly, see below.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new type script file
  2. Enter the code
    let text:string = 'I think my dog is cuter than your dog';
    log(text.replaceAll('dog', 'monkey'));
    // Expected output: "I think my monkey is cuter than your monkey"
  3. Start script
  4. Find in log the line I think my monkey is cuter than your monkey

Expected behavior
Editor should accept replaceAll as correct code, see here

Versions:

klein0r commented 5 months ago

This is because replaceAll function is only available starting from Node version 15.

I will raise the supported version to es2021 (since nodejs 16 is required for the latest adapter versions)