Skip to content

jsxRuntime pragma does not work #59340

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

Closed
clemyan opened this issue Jul 18, 2024 · 1 comment Β· Fixed by #59500
Closed

jsxRuntime pragma does not work #59340

clemyan opened this issue Jul 18, 2024 · 1 comment Β· Fixed by #59500
Assignees
Labels
feature-request A request for a new feature Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.

Comments

@clemyan
Copy link

clemyan commented Jul 18, 2024

πŸ”Ž Search Terms

jsxRuntime

πŸ•— Version & Regression Information

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

⏯ Playground Link

https://www.typescriptlang.org/play/?jsx=4&ts=5.6.0-dev.20240717#code/PQKgBAAgVgzgHgJQK4DsAuBLAtgUzAYwBsBDGGDfMEYAKBzgAcB7AJzQKZRnYAkdDCTAOqtCAEzABeMAAoAlFIB8YADwALAIyK+ApmADuosSuCbFAbiA

πŸ’» Code

/* @jsxRuntime classic */
export const HelloWorld = () => <h1>Hello world</h1>;

πŸ™ Actual behavior

The jsxRuntime pragma is not respected and function emit follows the jsx option in the TSConfig.

For example, with "jsx": "react-jsx", the function is emitted as

export const HelloWorld = () => _jsx("h1", { children: "Hello world" })

πŸ™‚ Expected behavior

The jsxRuntime pragma is respected and the function is emitted as

export const HelloWorld = () => React.createElement("h1", null, "Hello world")

Additional information about the issue

The code above is copied verbatim from the TSConfig Reference

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jul 26, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.7.0 milestone Jul 26, 2024
@weswigham weswigham added the feature-request A request for a new feature label Aug 1, 2024
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Aug 1, 2024
@clemyan
Copy link
Author

clemyan commented Sep 11, 2024

I see the linked PR is released in 5.6.2, but that only works when the jsx compiler option is react or react-jsx(dev), and so the pragma only allows switching between the two. The pragma is still ignored if jsx is react-native or preserve.

Is that intended?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A request for a new feature Fix Available A PR has been opened for this issue Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants