Skip to content

Port TypeScript PR #62338: Deprecate --moduleResolution node10#2817

Merged
jakebailey merged 6 commits intomainfrom
copilot/deprecate-module-resolution-node10
Mar 25, 2026
Merged

Port TypeScript PR #62338: Deprecate --moduleResolution node10#2817
jakebailey merged 6 commits intomainfrom
copilot/deprecate-module-resolution-node10

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 18, 2026

Ports microsoft/TypeScript#62338 to the Go codebase.

Fixes #2108

Core changes

  • internal/compiler/program.go: Add moduleResolution: node10 to the removed options list (TS7+ treats 6.0 deprecations as removed)
  • internal/ast/utilities.go: Add IsVariableDeclarationInitializedToBareOrAccessedRequire and GetModuleSpecifierOfBareOrAccessedRequire — handles accessed require patterns like require("foo").bar in addition to bare require("foo")
  • internal/checker/checker.go: Use the new utilities in resolveExternalModule to correctly resolve module specifiers from accessed require calls

Test updates

  • internal/execute/tsctests/tscbuild_test.go: Removed explicit "moduleResolution": "node" from resolveJsonModule tsbuild test configs so they default to bundler
  • internal/execute/tsctests/tsc_test.go: Removed explicit "moduleResolution": "node" from pnpm-style-layout tsc test config so it defaults to bundler

Already ported (no changes needed)

  • Default moduleResolution for --module commonjsbundler (GetModuleResolutionKind already maps this)
  • exportsOrImportsLookup returning bool in string_completions.go
  • detailsEntryId completions fix not applicable (pattern absent in Go port)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ort getModuleSpecifierOfBareOrAccessedRequire, update checker

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Port deprecation of --moduleResolution node10 Port TypeScript PR #62338: Deprecate --moduleResolution node10 Feb 18, 2026
Copilot AI requested a review from jakebailey February 18, 2026 03:58

tsgo --b project --v --explainFiles --listEmittedFiles
ExitStatus:: Success
ExitStatus:: DiagnosticsPresent_OutputsGenerated
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.

@copilot Change all of these tests to not use node10, but some other resolution mode

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed "moduleResolution": "node" from both the resolveJsonModule tsbuild test and the pnpm-style-layout tsc test configs. They now default to bundler instead. Baselines updated accordingly in 3dd2c9c.

…configs instead

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
@jakebailey jakebailey marked this pull request as ready for review March 24, 2026 22:48
Copilot AI review requested due to automatic review settings March 24, 2026 22:48
Copy link
Copy Markdown
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

Ports TypeScript PR microsoft/TypeScript#62338 into the Go port, updating option validation and module-specifier extraction to match upstream behavior and adjusting test baselines/configs accordingly.

Changes:

  • Treat --moduleResolution node10 as a removed option during compiler-option verification.
  • Extend require-pattern handling to extract module specifiers from accessed requires (e.g. require("x").y) and use that in resolveExternalModule.
  • Update tsc/tsbuild test inputs and reference baselines to stop explicitly setting "moduleResolution": "node" (so they default to bundler).

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/compiler/program.go Adds removed-option diagnostic when moduleResolution is Node10.
internal/ast/utilities.go Adds helper to extract module specifier from bare or accessed require(...) initializers.
internal/checker/checker.go Uses new AST helpers in resolveExternalModule to pick the right context specifier for resolution mode.
internal/execute/tsctests/tscbuild_test.go Removes explicit "moduleResolution": "node" from generated tsconfig in resolveJsonModule tsbuild tests.
internal/execute/tsctests/tsc_test.go Removes explicit "moduleResolution": "node" from pnpm-style-layout tsc test fixture.
testdata/baselines/reference/tsc/moduleResolution/pnpm-style-layout.js Updates reference baseline to reflect removed moduleResolution: node in the printed config.
testdata/baselines/reference/tsbuild/resolveJsonModule/without-outDir.js Updates reference baseline to reflect removed moduleResolution: node in the printed config.
testdata/baselines/reference/tsbuild/resolveJsonModule/without-outDir-non-composite.js Same as above (non-composite variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap.js Same as above (sourcemap variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/sourcemap-non-composite.js Same as above (non-composite variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-only.js Same as above (include-only variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-without-outDir.js Same as above (include-only/without-outDir variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-without-outDir-non-composite.js Same as above (non-composite variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory.js Same as above (json outside config dir variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-without-rootDir-but-outside-configDirectory-non-composite.js Same as above (non-composite variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-not-in-rootDir.js Same as above (json not in rootDir variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-with-json-not-in-rootDir-non-composite.js Same as above (non-composite variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-only-non-composite.js Same as above (non-composite include-only variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include.js Same as above (include json + other include variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-non-composite.js Same as above (non-composite variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js Same as above (filename-matches-ts variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-of-json-along-with-other-include-and-file-name-matches-ts-file-non-composite.js Same as above (non-composite variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-and-files.js Same as above (include+files variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/include-and-files-non-composite.js Same as above (non-composite variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file.js Same as above (files list contains json variant).
testdata/baselines/reference/tsbuild/resolveJsonModule/files-containing-json-file-non-composite.js Same as above (non-composite variant).

Comment thread internal/compiler/program.go
Comment thread internal/ast/utilities.go
Comment on lines +2820 to +2829
func GetModuleSpecifierOfBareOrAccessedRequire(node *Node) *Node {
if isVariableDeclarationInitializedWithRequireHelper(node, false /*allowAccessedRequire*/) {
return node.Initializer().Arguments()[0]
}
if isVariableDeclarationInitializedWithRequireHelper(node, true /*allowAccessedRequire*/) {
leftmost := GetLeftmostAccessExpression(node.Initializer())
if IsRequireCall(leftmost, true /*requireStringLiteralLikeArgument*/) {
return leftmost.Arguments()[0]
}
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This change adds support for extracting module specifiers from accessed-require initializers (e.g. const x = require("pkg").sub). There doesn’t appear to be a compiler test case in testdata/tests/cases/compiler/ that exercises this pattern, so regressions here would be hard to catch. Please add a minimal strict compiler test (likely a JS/TS pair with @allowJs/@checkJs) that fails without this change and passes with it.

Copilot generated this review using guidance from repository custom instructions.
@jakebailey jakebailey added this pull request to the merge queue Mar 25, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 25, 2026
@jakebailey jakebailey enabled auto-merge March 25, 2026 16:27
@jakebailey jakebailey added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit 14bce8c Mar 25, 2026
21 checks passed
@jakebailey jakebailey deleted the copilot/deprecate-module-resolution-node10 branch March 25, 2026 17:54
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.

Import containing a dot give an error

5 participants