Skip to content

never cannot be spread into object, but it can be spread into JSX propsΒ #48556

Closed
@knpwrs

Description

@knpwrs

Bug Report

πŸ”Ž Search Terms

  • props
  • never
  • spread

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about jsx, never, and spreads. This seems like a design limitation.

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

// @ts-ignore
const obj: never = {}

const obj2 = {...obj}
const el = <div {...obj} />

πŸ™ Actual behavior

As seen in kiliman/remix-params-helper#19, never is able to be spread into JSX props, even though never cannot be spread into objects. This seems odd to me as both compile to Object.assign. See screenshots:

TypeScript prevents spreading never into an object:

image

But spreading never into props works fine:

image

πŸ™‚ Expected behavior

never should be prevented from spreading into jsx props, just like it cannot be spread into objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions