Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 9, 2025

This PR ports the changes from microsoft/TypeScript#61813, which updates the tsc --init command to generate a new, more modern and opinionated tsconfig.json template.

Changes

New Template Structure

The new tsconfig.json template is organized into clear sections with opinionated defaults:

{
  // 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/module
    "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 (commented out as optional)
    // "noImplicitReturns": true,
    // ...

    // Recommended Options
    "strict": true,
    "jsx": "react-jsx",
    "verbatimModuleSyntax": true,
    "isolatedModules": true,
    "noUncheckedSideEffectImports": true,
    "moduleDetection": "force",
    "skipLibCheck": true,
  }
}

Implementation

  • Added GenerateTSConfig function in internal/tsoptions/commandlineparser.go that generates the structured template with helper functions to format compiler option values
  • Updated init handler in internal/execute/tsc.go to call the new function and display a success message
  • Added writeConfigFile function that creates the tsconfig.json file and handles errors when the file already exists

Key Differences from Previous Template

  • More opinionated: Enables modern best practices by default (strict, verbatimModuleSyntax, isolatedModules, etc.)
  • Better organized: Clear sections with descriptive comments
  • Focused output: Fewer commented options, showing only the most relevant settings
  • Modern defaults: Uses nodenext module resolution and esnext target

Testing

  • ✅ All existing tests pass with no baseline changes
  • ✅ Generated output matches TypeScript baseline exactly (verified with MD5 checksums)
  • ✅ Error handling works correctly when tsconfig.json already exists

Notes

This is a ground-up reimplementation rather than a line-by-line port, as suggested in the issue, due to structural differences between the TypeScript and Go implementations. The output matches the TypeScript version exactly.

Co-authored-by: RyanCavanaugh [email protected]

Original prompt

Re-implement the tsc --init update from TypeScript PR#61813. This will be difficult to port line-by-line, so prefer more of a ground-up reimplementation of the same endgoal

Note

Custom agent used: Strada to Corsa Port Expert
A Go and TypeScript expert who can easily figure out how to port PRs from one language to another


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Reimplement tsc --init functionality from TypeScript PR#61813 Port TypeScript PR#61813: Implement new tsc --init template Oct 9, 2025
Copilot finished work on behalf of RyanCavanaugh October 9, 2025 22:00
@Copilot Copilot AI requested a review from RyanCavanaugh October 9, 2025 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants