'TS Error - Property 'at' does not exist on type 'string[]

I dont know if this is a bug or something, but I simply cant remove the TS error in my IDE (Webstorm).

The error appears when I am using Array.prototype.at() on any kind of array.

tsconfig.json:

"lib": [
        "DOM",
        "ES2020",
        "ESNext"
    ],

But this seems not to work, I also added ES2021 - ES2015 but the error keeps on. It does work when I compile it, but I just get the error in the IDE.

Does anybody know how to fix this?

const arr = ["hello", 5, true, {name: "test"}];

console.log(arr.at(0));
console.log(arr.at(1));
console.log(arr.at(-1));
console.log(arr.at(-2));


Solution 1:[1]

Array.at requires ES2022 target which is available from TS 4.6 onwards.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matthieu Riegler