Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

TypeScript · Command

tsc --init

Initializes a TypeScript project by generating a tsconfig.json in the current directory. The current template is concise and supplies modern compiler defaults.

Since
TypeScript 1.6

How it works

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.

Syntax

tsc --init

Parameters

NameTypeDescription
--initbooleanInitializes a TypeScript project and creates a tsconfig.json file.

Returns

Creates a tsconfig.json file in the current directory.

Key points

  • Running the command in a directory creates that directory’s initial tsconfig.json.
  • With no additional options, generation follows the current release’s built-in template.
  • The generated configuration is oriented toward module-based applications rather than only global-script files.
  • The generated configuration can use module detection to ensure implementation files are interpreted as modules.
  • The current template targets modern ECMAScript capabilities by default.
  • Choosing the Node 20 module mode can establish an ES2023 target unless an explicit target overrides it.

Example: Create a project configuration

mkdir demo && cd demo
tsc --init
cat tsconfig.json

Creates a project configuration in the current directory, then displays the generated file.

When to use it

Generate an initial project configuration

Starting a new TypeScript project

Seed compiler settings

Bootstrapping a configuration for a selected runtime

Establish a shared configuration starting point

Creating a readable baseline for a large codebase

Interview questions

QWhat does 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.

QWhat artifact does the command create?

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.

QWhat kind of defaults does current 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.json
  • tsc
  • --moduleDetection
  • --module
  • --target
  • --strict

Source: Documentation - TypeScript 5.9. Checked 2026-10-15.