Skip to content

Infer the jsx property typeΒ #54851

Closed as not planned
Closed as not planned
@NWYLZW

Description

@NWYLZW

Bug Report

πŸ”Ž Search Terms

jsx, infer property

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about JSX

⏯ Playground Link

import React from 'react'

declare function A(props: {
  children:
    | React.ReactElement<{ test: 'aaaa' | 'bbbb' }>
}): React.ReactElement

declare function B<P extends Record<string, any>>(props: ...

Playground Link

πŸ’» Code

import React from 'react'

declare function A(props: {
  children:
    | React.ReactElement<{ test: 'aaaa' | 'bbbb' }>
}): React.ReactElement

declare function B<P extends Record<string, any>>(props: P): React.ReactElement<P>

const C = <A>
  <B test={'a'} />
  // ^? (property) test: string
  {B({
    test: 'aaaa'
  // ^? (property) test: 'aaaa'
  })}
</A>

πŸ™ Actual behavior

Infer test property is string type in JSX.

πŸ™‚ Expected behavior

Infer test property is 'aaaa' type in JSX.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions