lib (compiler option)
The compiler option that lists which built-in type declarations are available, such as ES2022 features or browser DOM types.
In more detail
lib only affects type checking: it tells the compiler which built-in objects and methods exist in your runtime. A Node.js project usually lists only an ECMAScript edition, while a browser project adds DOM. If lib is not set, it follows the target option.
Example
"lib": ["ES2022"]Related terms
- target (compiler option) — The compiler option that chooses which ECMAScript edition the emitted JavaScript uses, such as ES2022.
- declaration file — A file ending in .d.ts that contains only type information describing JavaScript that exists elsewhere, with no runnable code.
- skipLibCheck — The compiler option that skips type checking of all declaration files, including those of installed packages, to speed up builds.
Taught in
- tsconfig.json: target, lib, strict And NodeNext — Production TypeScript