Skip to content
Tutorials Center
My learning

Topics

TypeScript Reference ยท tsconfig: Projects, Files and Watch Options

TypeScript noLib and skipDefaultLibCheck options

Reference for the TypeScript noLib and skipDefaultLibCheck options: how to drop the default library, what breaks without it, and how it differs from skipLibCheck.

Every TypeScript program is compiled together with a default library: declaration files that describe Array, Promise, Math, the DOM and the rest of the runtime. Two options affect that library.

noLib stops the compiler from including the default library at all (including files chosen by lib). You must then declare the core global types yourself. It exists for people who target an unusual runtime or write their own base library.

skipDefaultLibCheck keeps the default library but skips type-checking of its declaration files. It is the older, narrower sibling of skipLibCheck, which skips every .d.ts file, and today skipLibCheck is normally the better choice.

JSON
{
  "compilerOptions": {
    "noLib": false,
    "skipDefaultLibCheck": true
  }
}

Try it

A real noLib program cannot run on this site, because even console comes from the default library. These examples show what a library provides and which names it must supply.

TypeScript The core globals that must exist

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

TypeScript What each option checks

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

Syntax

JSON
{ "compilerOptions": { "noLib": true, "skipDefaultLibCheck": true } }
TEXT
tsc --noLib
tsc --skipDefaultLibCheck
Option Description
noLib Boolean, default false. Omits the default library; combining it with lib is an error.
skipDefaultLibCheck Boolean, default false. Skips checking of default library declaration files only.

Edge cases: the compiler also requires the global IArguments interface, which has no runtime value. With noLib the compiler reports errors such as "Cannot find global type 'Array'" (TS2318) until your own declarations provide the required global interfaces.

Usage notes

  • Prefer skipLibCheck for speed and for dependency declaration conflicts; it covers the default library too.
  • noLib is for runtimes without standard globals, for example embedded scripting hosts. Write a small base declaration file, and add a /// <reference no-default-lib="true"/> directive in library files that are themselves the default library.
  • It hides real problems. Skipping checks means mistakes inside declaration files are never reported, only their effects when used.
  • Not a size optimization. The default library is not emitted; these options only change what is read and checked.
  • Use lib to pick a smaller set of built-in declarations before reaching for noLib.