I just installed fresh Visual Studio Code 1.23.1 on my MAC and opened a directory with one simple file main.ts (no tsconfig.json there):
function getFinalPrice(price: number, discount: number) {
return price - price/discount;
}
console.log(getFinalPrice(100, 10));
The word console is underlined with a squiggly red line, and the error reads:
[ts] Cannot file the name console".
I checked the installation directory of VS Code - it has the file .../extensions/node_modules/typescript/lib/lib.es2016.full.d.ts, which has this line:
declare var console: Console;
Why my VS Code doesn't pick it up?
My colleague tried the same code and he doesn't see this error. The only difference is that I have a freshly installed VS Code. What can be the problem?
Update: after adding a simple tsconfig.json file, the error is gone.
{
"compilerOptions": {
"noEmitOnError": true,
"target": "es5"
}
}
Is this a must to have tsconfig.json in VS Code projects?