The documentation says --lib
is derived from --target
by default:
Note: If --lib is not specified a default list of libraries are injected. The default libraries injected are:
- For --target ES5: DOM,ES5,ScriptHost
- For --target ES6: DOM,ES6,DOM.Iterable,ScriptHost
The same documentation says that the default --target
value is ES3:
Specify ECMAScript target version:
- "ES3" (default)
- "ES5"
- "ES6"/"ES2015"
- "ES2016"
- "ES2017"
- "ES2018"
- "ES2019"
- "ES2020"
- "ESNext"
So... what is --lib
default value when neither --lib
nor --target
is set?
In the source code there is a list of supported libs, which has a section called "Default libraries":
// Default libraries
"es5.full",
"es2015.full",
"es2016.full",
"es2017.full",
"es2018.full",
"es2019.full",
"es2020.full",
"es2021.full",
"esnext.full"
These correspond to your target setting.
Looking at the source code of one of these (lib.es2017.full.d.ts), you can see what it imports:
/// <reference lib="es2017" />
/// <reference lib="dom" />
/// <reference lib="webworker.importscripts" />
/// <reference lib="scripthost" />
/// <reference lib="dom.iterable" />
And FYI, all language levels import the previous. So for example: es2018 imports es2017, which imports es2016, which imports es2015, which imports es5. "es6" is unique because nothing imports it.
There appears to be no "es3" lib file in the source code, so I don't have an answer for that. Try setting noLib
, see what breaks, and comment below.