Just starting out with Typescript, I have a query regarding the lib
and target
properties. Below is my tsconfig.json
file:
{
"compilerOptions": {
"target": "es5",
"outDir": "./dist",
"rootDir": "./src",
"noEmitOnError": true,
}
}
//index.ts
console.log("Hello World");
Everything works flawlessly,
But when I wanted to use ES6 Map()
, I updated the configuration as follows:
{
"compilerOptions": {
"target": "es5",
"outDir": "./dist",
"rootDir": "./src",
"noEmitOnError": true,
"lib": ["es6"]
}
}
This change resulted in an error:
Cannot find name 'console'
My question is:
Q1 - Doesn't ES5 and ES6 already include the DOM API?
Q2 - If neither ES5 nor ES6 includes the DOM API, why did it work initially without the lib
property being set?