Conversation
There was a problem hiding this comment.
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
generateTSConfigsignature and implementation to remove file list parameter and output clean, sectioned JSON. - Updated
writeConfigFileand test invocations to match newgenerateTSConfigsignature. - 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.
| File | Description |
|---|---|
| src/compiler/commandLineParser.ts | Replaced old getCompilerOptionsDiffValue and rewritten generateTSConfig with new API. |
| src/compiler/executeCommandLine.ts | Updated writeConfigFile to call new generateTSConfig signature and cleaned output. |
| src/testRunner/unittests/config/initializeTSConfig.ts | Adjusted test helper to use new generateTSConfig(options, newLine) call. |
| src/compiler/diagnosticMessages.json | Inserted 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);
| 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 { |
There was a problem hiding this comment.
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)
tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json
Outdated
Show resolved
Hide resolved
| // Other Outputs | ||
| "sourceMap": true, | ||
| "declaration": true, | ||
| "declarationMap": true, |
There was a problem hiding this comment.
probably already discussed when i wasnt here, but declarationMap seems like overkill ? and additional cost?
There was a problem hiding this comment.
I'd suggest we just comment it out.
| // See also https://aka.ms/tsconfig/module | ||
| "module": "nodenext", | ||
| "target": "esnext", | ||
| "types": [], |
There was a problem hiding this comment.
Maybe a silly idea, but should we note the effect that this has?
| "files": [ | ||
| "file0.st", | ||
| "file1.ts", | ||
| "file2.ts" | ||
| ] |
There was a problem hiding this comment.
Is this intentional? I assume so?
|
Outside what I commented, everything is looking great. |
jakebailey
left a comment
There was a problem hiding this comment.
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.
|
There's a typo that caught my eye in the PR description. The code itself is fine. It should say |
|
Edited it. And it should also have said module=nodenext |
…pes` As recommended in TS 5.9: microsoft/TypeScript#61813
…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
Fixes #58420
Sample outputs
{ // 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, } }{ // 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, } }