TS2584
Cannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
Broken Code ❌
TypeScript code:
console.log('Hello, World!');TypeScript compiler configuration (tsconfig.json):
{
"compilerOptions": {
"lib": ["es2017"]
}
}Fixed Code ✔️
You have to add the following to your "tsconfig.json" file:
{
"compilerOptions": {
"lib": ["es2017", "dom"]
}
}When you are working on an application which never runs in a browser but only in Node.js environments, then you could add @types/node to your devDependencies instead of adding "dom" to your "lib" section.
