Port #63038: Consult referenced project options for synthetic default export eligibility#2752
Merged
jakebailey merged 2 commits intomainfrom Feb 12, 2026
Merged
Conversation
…thetic default export eligibility In canHaveSyntheticDefault, when GetImpliedNodeFormatForEmit returns no result for a declaration file, check if the file comes from a project reference. If so, use GetEmitModuleFormatOfFile to determine the module format from the referenced project's compiler options. When the usage is ESM and the target module kind is in the ES2015-ESNext range, deny synthetic defaults. Also adds a new test case "referenced project with esnext module disallows synthetic default imports" and updates affected baselines. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix consult referenced project options for synthetic default export
Port #63038: Consult referenced project options for synthetic default export eligibility
Feb 11, 2026
Member
DanielRosenwasser
approved these changes
Feb 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Ports TypeScript PR #63038 to ensure synthetic default imports are not permitted when importing a declaration file that comes from an ESM project reference, by consulting the referenced project’s emit module format.
Changes:
- Updated
Checker.canHaveSyntheticDefaultto consult referenced project compiler options (via project reference mapping) when implied node format can’t be determined for a.d.ts. - Added a new project-references tsc test case covering
module: esnextreferenced projects and synthetic default imports. - Updated/added tsc/tsbuild baselines to reflect the corrected TS1192 diagnostics and downstream type changes.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/checker/checker.go | Tightens canHaveSyntheticDefault by inferring module kind from referenced project options for redirected .d.ts files. |
| internal/execute/tsctests/tsc_test.go | Adds a focused regression test for ESM project references disallowing synthetic default imports. |
| testdata/baselines/reference/tsc/projectReferences/referenced-project-with-esnext-module-disallows-synthetic-default-imports.js | New baseline demonstrating TS1192 errors for default imports from ESM project reference outputs. |
| testdata/baselines/reference/tsc/projectReferences/default-import-interop-uses-referenced-project-settings.js | Baseline updated to include the new TS1192 errors for referenced project imports. |
| testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-with-non-moved-json-files-and-emits-them-correctly.js | Baseline updated to reflect TS1192 + resulting any types and updated tsbuildinfo diagnostics. |
Comment on lines
+14471
to
+14474
| // Try to get the project reference - try both source file mapping and output file mapping | ||
| // since declaration files can be mapped either way depending on how they're resolved | ||
| if c.program.GetRedirectForResolution(file.AsSourceFile()) != nil || c.program.GetProjectReferenceFromOutputDts(file.AsSourceFile().Path()) != nil { | ||
| // This is a declaration file from a project reference, so we can determine |
There was a problem hiding this comment.
The GetProjectReferenceFromOutputDts(...) != nil check appears redundant here: Program.GetRedirectForResolution already consults both the source-to-output and output-dts-to-source project reference maps (and symlink mapping). Dropping the extra lookup would simplify the condition and avoid implying there are two independent mechanisms to check.
Copilot AI
added a commit
that referenced
this pull request
Feb 25, 2026
… export eligibility (#2752) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a
.d.tsfile is resolved via a project reference, its module format was unknown, socanHaveSyntheticDefaultwould permissively allow synthetic defaults. This meantimport Foo from './lib'against an ESM project reference with only named exports produced no error.Changes
internal/checker/checker.go: IncanHaveSyntheticDefault, whenGetImpliedNodeFormatForEmitreturns no result for a declaration file, check whether the file originates from a project reference viaGetRedirectForResolutionorGetProjectReferenceFromOutputDts. If so, useGetEmitModuleFormatOfFileto resolve the module kind from the referenced project's options and deny synthetic defaults when both sides are ESM.internal/execute/tsctests/tsc_test.go: Added test case"referenced project with esnext module disallows synthetic default imports".💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.