thecodex.expert · The Codex Family of Knowledge
TypeScript

Setup and tsconfig

One JSON file controls everything about how strict your types are, which JavaScript version you target, and which files even get checked.

TypeScript 6.0 tsconfig.json Last verified:
Canonical Definition

TypeScript is installed via npm, providing the tsc command-line compiler (or, as of 2026, the newer Go-based tsgo in TypeScript 7.0). A tsconfig.json file at a project's root configures compiler behavior — which files to include, which JavaScript version to target, and how strict type-checking should be — and its presence is also what most editors use to provide TypeScript-aware autocomplete and error checking.

Installing and compiling

tsc compiles .ts files down to plain .js, stripping all type annotations in the process — the output is ordinary JavaScript with no trace of TypeScript syntax left in it.

TypeScriptterminal
$ npm install -D typescript
$ npx tsc --init          // generates a starter tsconfig.json
$ npx tsc                  // compiles every .ts file per tsconfig.json
$ npx tsc --watch          // recompiles automatically on save

A minimal tsconfig.json

strict: true enables the full family of strict type-checking rules (no implicit any, strict null checks, and more) in one flag — official TypeScript guidance recommends this for new projects, and TypeScript 6.0+ enables it by default.

TypeScripttsconfig.json
{
  "compilerOptions": {
    "target": "es2025",
    "module": "esnext",
    "strict": true,
    "outDir": "./dist"
  },
  "include": ["src/**/*"]
}

Running TypeScript without a separate compile step

Modern Node.js versions can run .ts files directly for development (type-stripping the syntax at runtime, without a full type-check), and tools like ts-node and tsx have long provided similar capability — useful for quick scripts and development, though a real build step (tsc) is still the standard for producing deployable JavaScript output.

Sources

1
Microsoft. TSConfig Reference, typescriptlang.org/tsconfig, and "What is a tsconfig.json", typescriptlang.org/docs/handbook/tsconfig-json.html.