When I try:
const myArray = [0,4,2];
myArray.at(-1);
I encounter the following error related to .at
The error message reads: Property 'at' does not exist on type 'number[]'.ts (2339)
Why is Array.at()
not working in this case? Is there a specific browserlist value that needs to be set in order for TypeScript to recognize and enable this recently specified feature?
Here is more information about Array.at() on MDN.
This is the content of my tsconfig.json file:
{
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"]
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}