Skip to content

Properties detectable as excess due to missing discriminant should be flagged in JSX expressions #43906

Open

Description

Bug Report

When using TSX syntax to create a element which props are typed as a discriminated union, validation works when given element is constructed in TSX syntax without children, but loses validation once you add children.

🔎 Search Terms

react createElement validation tsx jsx children throws

🕗 Version & Regression Information

  • This is the behavior in every version I tried (3.x - 4.3.0-beta)

⏯ Playground Link

Playground link with relevant code

💻 Code

// this one should error but does not because it has children (tsx syntax)
const B = (
  <Accordion defaultSelectedKeys={new Set()}>
    <span>1</span>
  </Accordion>
)
// while using createElement it does error (like it should)
React.createElement(Accordion, {defaultSelectedKeys:new Set<Key>()}, <span>1</span>)
// while these also error (like they should) because they are without children.
const X = <Accordion defaultSelectedKeys={new Set()} />
const Y = <Accordion multiple defaultSelectedKey="1" />

🙁 Actual behavior

Like shown above, while React.createElement throws like it should, using TSX syntax though, it stops working.

🙂 Expected behavior

Same behavior as with createElement - raise a validation error with children

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

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: JSX/TSXRelates to the JSX parser and emitter

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions