Port TS#62656: Fix TS2783 false positive for union types in object spread#2733
Merged
jakebailey merged 2 commits intomainfrom Feb 10, 2026
Merged
Port TS#62656: Fix TS2783 false positive for union types in object spread#2733jakebailey merged 2 commits intomainfrom
jakebailey merged 2 commits intomainfrom
Conversation
Port of microsoft/TypeScript#62656. Adds CheckFlags.Partial check in checkSpreadPropOverrides so that properties present in only some union constituents don't trigger the "always overwrites" error. Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix TS2783 false positive for union types in object spread
Port TS#62656: Fix TS2783 false positive for union types in object spread
Feb 10, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Ports the TypeScript fix for TS2783 false positives when spreading union types where a property exists in only some union constituents (“partial” properties).
Changes:
- Update
checkSpreadPropOverridesto also skipCheckFlags.Partialproperties when checking for guaranteed overwrites. - Update baseline error output to remove the incorrect TS2783/TS2785 report for the union-spread repro.
- Remove the corresponding baseline
.diffcontent now that the expected output is aligned.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| testdata/baselines/reference/submodule/compiler/spreadUnionPropOverride.errors.txt.diff | Removes the no-longer-applicable baseline diff for the previously incorrect diagnostic. |
| testdata/baselines/reference/submodule/compiler/spreadUnionPropOverride.errors.txt | Updates expected errors to no longer include the TS2783 false positive for id. |
| internal/checker/checker.go | Fixes the overwrite check by excluding properties marked CheckFlags.Partial (not guaranteed in all union constituents). |
sandersn
approved these changes
Feb 10, 2026
Copilot AI
added a commit
that referenced
this pull request
Feb 25, 2026
…read (#2733) 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.
Ports microsoft/TypeScript#62656.
checkSpreadPropOverridesreported TS2783 ("specified more than once, so this usage will be overwritten") for properties that only exist in some constituents of a spread union type. These partial properties are marked withCheckFlags.Partial, but the function only checkedSymbolFlags.Optional.Example that previously false-positived:
The
{ label: 'Foo' }fallback has noid, so the overwrite is not guaranteed — error was incorrect.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.