Skip to content

Shallow copy of Map class produce incorrect typings #59389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bacebu4 opened this issue Jul 22, 2024 · 1 comment
Closed

Shallow copy of Map class produce incorrect typings #59389

bacebu4 opened this issue Jul 22, 2024 · 1 comment

Comments

@bacebu4
Copy link

bacebu4 commented Jul 22, 2024

πŸ”Ž Search Terms

shallow copy, wrong shallow copy type, destructuring map class

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.5.3#code/MYewdgzgLgBAhjAvDMBTA7jAsnADgCgEoBuAKFElgCMkYBvAOibgF9zwIQAbVBrkAOb4qDAaiiEgA

πŸ’» Code

const a = new Map();
const b = {...a}
console.log(b.get)

πŸ™ Actual behavior

According to types, b.get is defined, but it is actually undefined

πŸ™‚ Expected behavior

b should not have methods of Map class after shallow copying it

Additional information about the issue

No response

@MartinJohns
Copy link
Contributor

MartinJohns commented Jul 22, 2024

Duplicate of #53765 / #53747. Used search terms: spread map in:title

The relevant issue for this is #9726.

@bacebu4 bacebu4 closed this as completed Jul 22, 2024
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

No branches or pull requests

2 participants