Generate an initial project configuration
Starting a new TypeScript project
TypeScript · Command
Initializes a TypeScript project by generating a tsconfig.json in the current directory. The current template is concise and supplies modern compiler defaults.
Running tsc --init asks the TypeScript compiler to initialize a project by creating a tsconfig.json in the current directory. In current TypeScript, the generated configuration uses a concise set of defaults; command-line options supplied alongside --init can be written into the initial configuration.
tsc --init| Name | Type | Description |
|---|---|---|
--init | boolean | Initializes a TypeScript project and creates a tsconfig.json file. |
Creates a tsconfig.json file in the current directory.
tsconfig.json.mkdir demo && cd demo
tsc --init
cat tsconfig.jsonCreates a project configuration in the current directory, then displays the generated file.
Starting a new TypeScript project
Bootstrapping a configuration for a selected runtime
Creating a readable baseline for a large codebase
tsc --init do?tsc --init creates an initial tsconfig.json for the current directory. The file provides project configuration that later compiler invocations can use.
Follow-up: How can you customize the generated configuration immediately? Supply compiler command-line options together with --init; those options are stored in the initial file.
The command initializes a TypeScript project and creates a tsconfig.json file. It is a project-setup operation rather than a command that compiles a specified source file.
Follow-up: What happens when source files are explicitly passed to tsc? The compiler ignores tsconfig.json for that invocation and uses the command-line file inputs.
tsc --init generate?The current TypeScript 5.9 documentation describes a plain invocation as producing a minimal configuration with defaults such as module: "nodenext" and target: "esnext". The generated file also includes settings for project layout and type inclusion.
Follow-up: Why might a project override these defaults? Its runtime, module system, source layout, or required ambient type packages may differ from the generated assumptions.
tsconfig.jsontsc--moduleDetection--module--target--strict