Skip to content

tsc --init update - #61813

Merged
Ryan Cavanaugh (RyanCavanaugh) merged 14 commits into
microsoft:mainfrom
RyanCavanaugh:tsc-init
Jun 6, 2025
Merged

tsc --init update#61813
Ryan Cavanaugh (RyanCavanaugh) merged 14 commits into
microsoft:mainfrom
RyanCavanaugh:tsc-init

Conversation

@RyanCavanaugh

@RyanCavanaughRyan Cavanaugh (RyanCavanaugh) commented Jun 4, 2025

Copy link
Copy Markdown
Member

Fixes#58420

Sample outputs

tsc --init

{
// Visit https://aka.ms/tsconfig to read more about this file"compilerOptions": {
// File Layout// "rootDir": "./src",// "outDir": "./dist",// Environment Settings// See also https://aka.ms/tsconfig_modules"module": "nodenext",
"target": "esnext",
"types": [],
// For nodejs:// "lib": ["esnext"],// "types": ["node"],// and npm install -D @types/node// Other Outputs"sourceMap": true,
"declaration": true,
"declarationMap": true,
// Stricter Typechecking Options"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
// Style Options// "noImplicitReturns": true,// "noImplicitOverride": true,// "noUnusedLocals": true,// "noUnusedParameters": true,// "noFallthroughCasesInSwitch": true,// "noPropertyAccessFromIndexSignature": true,// Recommended Options"strict": true,
"jsx": "react-jsx",
"verbatimModuleSyntax": true,
"isolatedModules": true,
"noUncheckedSideEffectImports": true,
"moduleDetection": "force",
"skipLibCheck": true,
}
}

tsc --init --noImplicitAny false --target es2022 --lib dom --rootDir src --types mocha --noImplicitReturns

{
// Visit https://aka.ms/tsconfig to read more about this file"compilerOptions": {
// File Layout"rootDir": "src",
// "outDir": "./dist",// Environment Settings// See also https://aka.ms/tsconfig_modules"module": "nodenext",
"target": "es2022",
"types": ["mocha"],
"lib": ["dom"],
// For nodejs:// "lib": ["esnext"],// "types": ["node"],// and npm install -D @types/node// Other Outputs"sourceMap": true,
"declaration": true,
"declarationMap": true,
// Stricter Typechecking Options"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
// Style Options"noImplicitReturns": true,
// "noImplicitOverride": true,// "noUnusedLocals": true,// "noUnusedParameters": true,// "noFallthroughCasesInSwitch": true,// "noPropertyAccessFromIndexSignature": true,// Recommended Options"strict": true,
"jsx": "react-jsx",
"verbatimModuleSyntax": true,
"isolatedModules": true,
"noUncheckedSideEffectImports": true,
"moduleDetection": "force",
"skipLibCheck": true,
"noImplicitAny": false,
}
}

This comment was marked as outdated.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Updates the --init logic to streamline how tsconfig.json is generated and simplify related tests and CLI handling. Key changes include:

  • Refactored generateTSConfig signature and implementation to remove file list parameter and output clean, sectioned JSON.
  • Updated writeConfigFile and test invocations to match new generateTSConfig signature.
  • Added diagnostic message entries for each new section header.

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

FileDescription
src/compiler/commandLineParser.tsReplaced old getCompilerOptionsDiffValue and rewritten generateTSConfig with new API.
src/compiler/executeCommandLine.tsUpdated writeConfigFile to call new generateTSConfig signature and cleaned output.
src/testRunner/unittests/config/initializeTSConfig.tsAdjusted test helper to use new generateTSConfig(options, newLine) call.
src/compiler/diagnosticMessages.jsonInserted new diagnostic entries for section headers used in generated JSON.
Comments suppressed due to low confidence (1)

src/compiler/commandLineParser.ts:2930

  • Consider appending a trailing newline to the generated config for consistency with existing baselines and editor tooling. For example: return result.join(newLine) + newLine;
 return result.join(newLine);

Comment threadsrc/compiler/diagnosticMessages.json
Comment threadsrc/compiler/diagnosticMessages.json Outdated
export function generateTSConfig(options: CompilerOptions, fileNames: readonly string[], newLine: string): string {
const compilerOptionsMap = getSerializedCompilerOption(options);
return writeConfigurations();
export function generateTSConfig(options: CompilerOptions, newLine: string): string {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was like "oh no, hope nobody calls this", but no, it's all callers from 5+ years ago (https://github.com/search?q=%2Fts%28+as+%5B%5E%28%5D%2B%5C%29%29%3F%5C.generateTSConfig%5C%28%2F+-path%3Atestrunner&type=code)

@github-project-automationgithub-project-automationBot moved this from Not started to Needs merge in PR BacklogJun 4, 2025
// Other Outputs
"sourceMap": true,
"declaration": true,
"declarationMap": true,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably already discussed when i wasnt here, but declarationMap seems like overkill ? and additional cost?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest we just comment it out.

// See also https://aka.ms/tsconfig/module
"module": "nodenext",
"target": "esnext",
"types": [],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a silly idea, but should we note the effect that this has?

Comment on lines -113 to -117
"files": [
"file0.st",
"file1.ts",
"file2.ts"
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? I assume so?

@jakebailey

Copy link
Copy Markdown
Member

Outside what I commented, everything is looking great.

@jakebaileyJake Bailey (jakebailey) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, giving this another +1 since it's what was spec'd out, but if we do want to drop declarationMap that's fine too.

@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) merged commit cd34199 into microsoft:mainJun 6, 2025
@github-project-automationgithub-project-automationBot moved this from Needs merge to Done in PR BacklogJun 6, 2025
@robpalme

Copy link
Copy Markdown

There's a typo that caught my eye in the PR description. The code itself is fine.

 "target": "nodenext",

It should say "esnext"

@jakebailey

Copy link
Copy Markdown
Member

Edited it. And it should also have said module=nodenext

Haoqun Jiang (haoqunjiang) added a commit to vuejs/tsconfig that referenced this pull request Jul 17, 2025
Haoqun Jiang (haoqunjiang) added a commit to vuejs/tsconfig that referenced this pull request Aug 15, 2025
…pes` (#36)
See https://www.semver-ts.org/formal-spec/5-compiler-considerations.html#strictness for the arguments for turning these options on.
Both are now turned on by default in the `tsc --init` template of TS 5.9 microsoft/TypeScript#61813
@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Apr 17, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: TeamFor Uncommitted BugPR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

tsc --init update 2024

7 participants

@RyanCavanaugh@jakebailey@robpalme@sheetalkamat@andrewbranch@typescript-bot