Skip to content

Fix resolveJsonModule default for nodenext module#2657

Merged
jakebailey merged 3 commits intomainfrom
copilot/fix-resolve-json-module
Feb 3, 2026
Merged

Fix resolveJsonModule default for nodenext module#2657
jakebailey merged 3 commits intomainfrom
copilot/fix-resolve-json-module

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

resolveJsonModule was not defaulting to true when module is nodenext, causing errors when importing JSON files without explicitly setting the option.

// tsconfig.json: { "compilerOptions": { "module": "nodenext" } }
import pkg from './package.json' with { type: 'json' };
// tsc 5.9.3: ✅
// tsgo before fix: "Consider using '--resolveJsonModule' to import module with '.json' extension."

Changes

  • Fixed the switch case in GetResolveJsonModule() to include ModuleKindNodeNext alongside ModuleKindNode20, and removed ModuleKindESNext which shouldn't have been there per the TypeScript implementation
Original prompt

This section details on the original issue you should resolve

<issue_title>resolveJsonModule is not defaulted to true when module is nodenext</issue_title>
<issue_description>## Steps to reproduce

TS:

import packageJson from './package.json' with { type: 'json' };

Result:

"module": tsc 5.9.3 tsgo 7.0.0-dev.20260203.1
"node20"
"nodenext" Consider using '--resolveJsonModule' to import module with '.json' extension.

<agent_instructions>Cross-compare the linked TypeScript and typescript-go PRs to look for differences to help find a fix.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix resolveJsonModule for nodenext module Fix resolveJsonModule default for nodenext module Feb 3, 2026
Copilot AI requested a review from jakebailey February 3, 2026 17:26
@jakebailey jakebailey marked this pull request as ready for review February 3, 2026 17:42
Copilot AI review requested due to automatic review settings February 3, 2026 17:42
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where resolveJsonModule was not defaulting to true when the module compiler option is set to nodenext, causing errors when importing JSON files without explicitly setting the option.

Changes:

  • Added ModuleKindNodeNext to the switch case in GetResolveJsonModule() to ensure it defaults to true alongside ModuleKindNode20 and ModuleKindESNext

@jakebailey jakebailey added this pull request to the merge queue Feb 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 3, 2026
@jakebailey jakebailey added this pull request to the merge queue Feb 3, 2026
Merged via the queue into main with commit a7cb03e Feb 3, 2026
20 checks passed
@jakebailey jakebailey deleted the copilot/fix-resolve-json-module branch February 3, 2026 18:57
Copilot AI added a commit that referenced this pull request Feb 25, 2026
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
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.

resolveJsonModule is not defaulted to true when module is nodenext

5 participants