#Errors broken in VS Code?

10 messages · Page 1 of 1 (latest)

glacial garnet
#
const orderQueue = [];
orderQueue[0] = { id: 1, name: 'Order 1' };

console.log(orderQueue)

Its obvious this code will cause an error, but why isn't it displaying the error in my VS Code?

Any help appreciated, please ping with response.

#

Also very weird when I run tsc build it doesn't show any errors either.

#

I thought TS was supposed to find errors or bugs before you even build it?

#
{
    "compilerOptions": {
        "module": "NodeNext",
        "moduleResolution": "NodeNext",
        "target": "ESNext",
        "sourceMap": true,
        "outDir": "dist",
        "strict": true,
        "noImplicitAny": true
    },
    "include": ["src/**/*"]
}
torn zinc
#

What error are you expecting? By declaring the array in that fashion orderQueue is any[]

#

Arguably something like that could be caught by noImplicitAny but doesn't seem to be

torn zinc
#

If you want the array to be immutable you can declare it as readonly:

const foo : readonly any[] = []

glacial garnet