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

Enable JSX.Element to be checked based on the element type #59671

Closed
6 tasks done
thesoftwarephilosopher opened this issue Aug 17, 2024 · 3 comments
Closed
6 tasks done
Labels
Duplicate An existing issue was already created

Comments

@thesoftwarephilosopher
Copy link

thesoftwarephilosopher commented Aug 17, 2024

πŸ” Search Terms

JSX IntrinsicElements Element

βœ… Viability Checklist

⭐ Suggestion

The docs currently say:

By default the result of a JSX expression is typed as any. You can customize the type by specifying the JSX.Element interface. However, it is not possible to retrieve type information about the element, attributes or children of the JSX from this interface. It is a black box.

This proposal is to somehow allow specifying types so that it can be decided by tsc:

const status = <p class='status' />; // type = HTMLParagraphElement

πŸ“ƒ Motivating Example

The examples on https://vanillajsx.com/ all have assertions like as HTMLParagraphElement.

This change would enable custom JSX libraries easier to specify that "p": HTMLParagraphElement to avoid this.

πŸ’» Use Cases

  1. What do you want to use this for?

Iterate on experimental JSX implementations.

  1. What shortcomings exist with current approaches?

Explicitly asserting JSX element types.

  1. What workarounds are you using in the meantime?

Explicitly asserting JSX element types.

@MartinJohns
Copy link
Contributor

Duplicate of #21699.

@thesoftwarephilosopher
Copy link
Author

@MartinJohns I don't think so... I think I just got it working a few minutes ago with JSX.ElementType but I can't repro. But if I can, then this is already solved...

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Aug 19, 2024
@typescript-bot
Copy link
Collaborator

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

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2024
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