Skip to content

Port TypeScript #62722: Widen reverse mapped type properties#2744

Merged
jakebailey merged 2 commits intomainfrom
copilot/widen-reverse-mapped-types
Feb 12, 2026
Merged

Port TypeScript #62722: Widen reverse mapped type properties#2744
jakebailey merged 2 commits intomainfrom
copilot/widen-reverse-mapped-types

Conversation

Copy link
Contributor

Copilot AI commented Feb 10, 2026

Reverse mapped type inference was returning unwidened literal types, causing them to be treated as valid sources for Excess Property Checking (EPC). This produced spurious errors like 'default' does not exist in type '{ type: unknown; }' when using reverse mapped types with literal-valued properties.

Ported from microsoft/TypeScript#62722.

  • Wrap inferReverseMappedTypeWorker return with getWidenedType() so inferred property types like false widen to boolean
// Before
return core.OrElse(c.getTypeFromInference(inference), c.unknownType)

// After
return c.getWidenedType(core.OrElse(c.getTypeFromInference(inference), c.unknownType))
  • Baseline updates: 4 .diff files and 2 error baselines deleted (Go now matches TS output for these cases)

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

Wrap the return value of inferReverseMappedTypeWorker with getWidenedType()
to fix reverse mapped type properties being treated as EPC-valid sources.

This matches the TypeScript change at:
microsoft/TypeScript#62722

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Port reverse mapped type properties fix Port TypeScript #62722: Widen reverse mapped type properties Feb 11, 2026
Copilot AI requested a review from jakebailey February 11, 2026 00:05
@jakebailey jakebailey marked this pull request as ready for review February 11, 2026 00:17
Copilot AI review requested due to automatic review settings February 11, 2026 00:17
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

Ports TypeScript behavior for reverse mapped type inference by widening inferred property types to avoid spurious Excess Property Checking (EPC) errors, and updates/removes baselines accordingly.

Changes:

  • Widen the return type of inferReverseMappedTypeWorker via getWidenedType(...).
  • Update .types baselines for reverse mapped type inference widening scenarios.
  • Remove now-unneeded .diff baselines and clear error baselines that should no longer report EPC errors.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/checker/inference.go Widen reverse mapped type inference results to avoid propagating literal types into EPC.
testdata/baselines/reference/submodule/compiler/reverseMappedTypeInferenceWidening2.types Updates expected type output for the “widening2” scenario.
testdata/baselines/reference/submodule/compiler/reverseMappedTypeInferenceWidening1.types Updates expected type output for the “widening1” scenario.
testdata/baselines/reference/submodule/compiler/reverseMappedTypeInferenceWidening2.types.diff Removes obsolete baseline diff after output alignment.
testdata/baselines/reference/submodule/compiler/reverseMappedTypeInferenceWidening1.types.diff Removes obsolete baseline diff after output alignment.
testdata/baselines/reference/submodule/compiler/reverseMappedTypeInferenceWidening2.errors.txt.diff Removes obsolete error diff baseline (errors no longer expected).
testdata/baselines/reference/submodule/compiler/reverseMappedTypeInferenceWidening1.errors.txt.diff Removes obsolete error diff baseline (errors no longer expected).
testdata/baselines/reference/submodule/compiler/reverseMappedTypeInferenceWidening2.errors.txt Clears expected errors (now none).
testdata/baselines/reference/submodule/compiler/reverseMappedTypeInferenceWidening1.errors.txt Clears expected errors (now none).

@jakebailey jakebailey enabled auto-merge February 11, 2026 01:33
@jakebailey jakebailey added this pull request to the merge queue Feb 12, 2026
Merged via the queue into main with commit 7316bb2 Feb 12, 2026
26 checks passed
@jakebailey jakebailey deleted the copilot/widen-reverse-mapped-types branch February 12, 2026 17:01
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.

4 participants