Skip to content

Conversation

remcohaszing
Copy link
Contributor

This adds some missing information about using JSX in TypeScript.

  • Add the react-jsx and react-jsxdev modes in the introduction. Also mention they are called the classic and automatic runtime.
  • Specify where frameworks need to specify the JSX namespace.
  • Clarify which jsx options use which type definitions.
  • Specify that JSX runtimes must use package exports in order to support ESM.
  • Fix syntax highlighting in JSX code blocks.
  • Document that users may use the @jsxRuntime comment to override the jsx option on a per-file basis.

This adds some missing information about using JSX in TypeScript.

- Add the `react-jsx` and `react-jsxdev` modes in the introduction. Also
  mention they are called the classic and automatic runtime.
- Specify where frameworks need to specify the `JSX` namespace.
- Clarify which `jsx` options use which type definitions.
- Specify that JSX runtimes must use package exports in order to support
  ESM.
- Fix syntax highlighting in JSX code blocks.
- Document that users may use the `@jsxRuntime` comment to override the
  `jsx` option on a per-file basis.
@jakebailey jakebailey added the deploy-preview Enables automatic deployments to preview environments on a PR label Apr 18, 2024
@jakebailey
Copy link
Member

Is there anyone who might be able to help verify this? @weswigham maybe? @DanielRosenwasser?

@orta
Copy link
Contributor

orta commented Apr 26, 2024

I can at least confirm that this is how I model the JSX support in my head (I think people are re-looking at this because React 19 is starting to come out) after giving it a look though.

The only bits I'm not certain of are the ESM support docs, because I've not had to interact with that system. Feels reasonable to me though.

@remcohaszing
Copy link
Contributor Author

Missing package exports are the reason why the automatic runtime in react@<18 didn’t work with ESM.

remcohaszing and others added 3 commits June 6, 2024 15:28
Co-authored-by: Sebastian Silbermann <[email protected]>
Since it’s also possible to define the `JSX` namespace globally, `needs
to` is a bit to strong. It was replaced with `should`.
Copy link
Contributor

github-actions bot commented Jun 7, 2024

Azure Static Web Apps: Your stage site is ready! Visit it here: https://victorious-plant-05c166c10-3064.centralus.5.azurestaticapps.net

@jakebailey
Copy link
Member

Gave this a reread, and everything seems to check out to me.

@jakebailey jakebailey merged commit 57ac2f7 into microsoft:v2 Jul 8, 2024
@remcohaszing remcohaszing deleted the update-jsx-docs branch July 8, 2024 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy-preview Enables automatic deployments to preview environments on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants