Error in Typescript, but the code runs successfully in Cocos, any way to change this default behaviour?

There is an error assigning string to foo:


VS Code can recognize this error.
But the code runs successfully in Cocos (with no error).

Contrary to Cocos, if there is error in Typescript, script run by “ts-node”( from “node.js” ) will stop with error.
Is there any way to change the behaviour in Cocos ? I would like it to be something like ts-node, which doesn’t ignore typescript error.

Cocos Version: 3.8.1

you shouldn’t declare foo as a number, then later assign a string to it

The mistake is intentional.
I want to trigger an error to see if it can stop the game.