GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Object.assign return assigned type instead merged by anion155 · Pull Request #28553 · microsoft/TypeScript

Conversation

@anion155

@anion155 Anton Mikhailov (anion155) commented Nov 15, 2018

Copy link
Copy Markdown

Got 'assing' in my eyes. Found some old bugs created in 16 (#11100). So I made this quick PR.

Situation:

let a = {
  a: 'string',
  b: { c: 4 },
};
let b = {
  a: 5,
  b: { d: 3 },
}
Object.assign({ }, a, b);

Result of this operation is { a: 5, b: { d: 3 } }, but TS says its of { a: string & number; b: { c: number; d: number; } } type, which is obviously wrong (according to mozilla's JS reference).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@anion155
Object.assign return assigned type instead merged
777a252
@sandersn

Nathan Shively-Sanders (sandersn) commented Nov 19, 2018

Copy link
Copy Markdown
Member

We actually decided recently to double down on this incorrect definition of spread and Object.assign in #28234. In practise, the most common use of spread is to spread two identical types. The second most common use is to spread two disjoint types. Spreading two overlapping types is pretty rare, so we decided not to create a type operator for it.

Also note that Assign is still not correct, since it doesn't understand own properties, optional properties, or private properties. getSpreadType handles these aspects, but doesn't work for higher-order cases since we didn't create the spread type operator.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sandersn Nathan Shively-Sanders (sandersn) closed this Nov 19, 2018
@jcalz Joe Calzaretta (jcalz) mentioned this pull request Jun 19, 2019
Bug Report + Proposal: Object.assign() #31982
Closed
@karlhorky Karl Horky (karlhorky) mentioned this pull request Jul 4, 2019
Full Handbook Page on Soundness microsoft/TypeScript-Handbook#1059
Open
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
@typescript-bot

TypeScript Bot (typescript-bot) commented Oct 21, 2025

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@anion155 @sandersn @typescript-bot
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.