Skip to content

Merging objects by spreading 2 objects infers wrong type #61840

Closed as duplicate of#27273
@zanminkian

Description

@zanminkian

πŸ”Ž Search Terms

spread object as const record

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried.

⏯ Playground Link

No response

πŸ’» Code

const x = {'foo': 'bar'} as const
const y: Record<string, string|boolean> = {'foo': true}
const z = {...x, ...y}

Image

πŸ™ Actual behavior

Type of z is {'foo':'bar'}

πŸ™‚ Expected behavior

Type of z should be Record<string, string|boolean> or {'foo':'bar'}&Record<string, string|boolean>

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions