TypeScript Compiler Options
--project — TypeScript CLI
Selects a specific configuration rather than the implicit configuration discovered from the current working directory. Supply either a directory containing tsconfig.json or a JSON configuration file. Input files are selected by that configuration; explicit source file arguments cannot be combined with --project (TS5042). For building reference graphs use --build. Baseline: TypeScript 5.8.3. Commands are run with the pinned local compiler in an isolated directory; omit file labels. CLI-only setting.
Formal Syntax & Structure
typescript syntaxtypescript
tsc --project <directory-or-config-file> | tsc -p <path>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| project | string | Path to the configuration file or directory; required when the flag is used. |
Working Example
Example Snippettypescript
// File: app/tsconfig.json (omit this label){ "compilerOptions": { "target": "ES2022", "module": "CommonJS", "strict": true, "types": [], "outDir": "dist" }, "files": [ "index.ts" ]}// File: app/index.ts (omit this label)export const count = 7;console.log(count);// File: other.ts (omit this label)const bad: number = "bad";
// Run in a temporary project:// tsc -p app --pretty false// node app/dist/index.js