A tsconfig.json that sets outDir but not rootDir was the usual minimal setup for years, and it is how this page showed it until October 2026. Under TypeScript 6.0 it fails: tsc reports TS5011, asking for an explicit rootDir. Because tsc still emits on error, the output also moves one folder deeper, to dist/src/index.js, so any script that runs dist/index.js breaks as well.
{
"compilerOptions": {
"target": "es2025",
"module": "esnext",
"strict": true,
"outDir": "./dist"
},
"include": ["src/**/*"]
}$ tsc
tsconfig.json(6,5): error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout.
Visit https://aka.ms/ts6 for migration information.
$ find dist -type f
dist/src/index.jsTypeScript 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.
$ 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 saveA 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.
{
"compilerOptions": {
"target": "es2025",
"module": "esnext",
"strict": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"]
}The minimal config above now includes "rootDir": "./src", which is all TypeScript 6.0 needs. With it, the build is clean and the output lands where scripts expect it. (Verified with tsc 6.0.3 on a one-file project; the Compiler page explains why the folder layout depends on rootDir.) The tsc --init command in the first section is a safe start, too: in 6.0.3 it writes a strict config with no outDir at all, so this only bites once you add an output folder.
$ tsc
$ find dist -type f
dist/index.jsRunning 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.