TypeScript Compiler Options
--init — TypeScript CLI
Creates a starter tsconfig.json in the current directory. The generated defaults and comments depend on compiler version; 5.8.3 generates a commented template with strict mode and ES2016 target. Review the settings for the intended host. A second initialization refuses to replace an existing config (TS5054). In 5.8.3 this diagnostic is printed with exit status zero; inspect the diagnostic and file, not just the exit status. It does not install dependencies or compile a program. 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 --initParameters & Attributes
| Name | Type | Description |
|---|---|---|
| init | boolean | Optional command switch; omit to leave the command inactive. |
Working Example
Example Snippettypescript
// File: index.ts (omit this label)export const count: number = 7;
// Run in a temporary project:// tsc --init --pretty false// tsc --showConfig