Skip to content
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

When spread array into object literal, Returns a type containing unnecessary properties #52060

Closed
GunseiKPaseri opened this issue Dec 31, 2022 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@GunseiKPaseri
Copy link

Bug Report

πŸ”Ž Search Terms

Spread Syntax, Array into object literal

πŸ•— Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries about rest syntax.

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

const x = ["a", "b", "c"]
console.log(x)
const y = {...x}
//    expected {[x: number]: string} etc, but got {[x: number]: string, length: number, toString(): string .....}

console.log(y.length) // undefined
//  expected undefined, but got number

πŸ™ Actual behavior

y(spread array into object literal) 's property type is same as Array

πŸ™‚ Expected behavior

y(spread array into object literal) 's property has only array value.

@MartinJohns
Copy link
Contributor

Essentially a duplicate of #9726.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 3, 2023
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants