Modules, Runtime & Tooling

tsconfig & Module Resolution

tsconfig.json controls how TypeScript checks and emits a project: target, module system, strictness, JSX, included files, path aliases, library types, and resolution rules.
  • target controls emitted JavaScript syntax
  • module controls emitted module format
  • moduleResolution controls how imports are found
  • lib controls available ambient types
  • Strictness is part of architecture
App-oriented tsconfig shape
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "lib": ["ES2022", "DOM", "DOM.Iterable"],
    "strict": true,
    "noUncheckedIndexedAccess": true,
    "exactOptionalPropertyTypes": true
  },
  "include": ["src"]
}
The right settings depend on runtime, bundler, and project type.
Important tsconfig options
OptionControlsCommon mistake
targetOutput syntaxAssuming it polyfills APIs
moduleOutput module formatMismatch with runtime
moduleResolutionHow imports resolveUsing old mode with modern exports
libAvailable ambient typesTyping APIs not present in runtime
strictType-checking baselineLeaving it off indefinitely
pathsCompile-time aliasesForgetting runtime/bundler support
Sources
  • The TypeScript HandbookProject Configuration
  • TypeScript ReferenceTSConfig Reference
  • Node.js Documentation and Learn Node.jsTypeScript in Node.js