@@ -108,6 +108,22 @@ Yields:
108
108
<h1 >Hello, world!</h1 >
109
109
```
110
110
111
+ > ** Note** :
112
+ > To add proper type support in React\@ 19,
113
+ > register a global JSX namespace:
114
+ >
115
+ > ``` ts
116
+ > import type {JSX as Jsx } from ' react/jsx-runtime'
117
+ >
118
+ > declare global {
119
+ > namespace JSX {
120
+ > type ElementClass = Jsx .ElementClass
121
+ > type Element = Jsx .Element
122
+ > type IntrinsicElements = Jsx .IntrinsicElements
123
+ > }
124
+ > }
125
+ > ` ` `
126
+
111
127
## API
112
128
113
129
This package exports the identifier [ ` toJsxRuntime ` ][api-to-jsx-runtime].
@@ -517,6 +533,21 @@ render(
517
533
)
518
534
```
519
535
536
+ To add proper type support,
537
+ register a global JSX namespace:
538
+
539
+ ``` ts
540
+ import type {JSX as Jsx } from ' preact/jsx-runtime'
541
+
542
+ declare global {
543
+ namespace JSX {
544
+ type ElementClass = Jsx .ElementClass
545
+ type Element = Jsx .Element
546
+ type IntrinsicElements = Jsx .IntrinsicElements
547
+ }
548
+ }
549
+ ```
550
+
520
551
### Example: Solid
521
552
522
553
> 👉 ** Note** : you must set ` elementAttributeNameCase: 'html' ` and
@@ -567,6 +598,21 @@ function Component() {
567
598
}
568
599
```
569
600
601
+ To add proper type support,
602
+ register a global JSX namespace:
603
+
604
+ ``` ts
605
+ import type {JSX as Jsx } from ' solid-js/jsx-runtime'
606
+
607
+ declare global {
608
+ namespace JSX {
609
+ type ElementClass = Jsx .ElementClass
610
+ type Element = Jsx .Element
611
+ type IntrinsicElements = Jsx .IntrinsicElements
612
+ }
613
+ }
614
+ ```
615
+
570
616
### Example: Svelte
571
617
572
618
<!-- To do: improve svelte when it fixes a bunch of bugs. -->
@@ -590,6 +636,9 @@ Yields:
590
636
[class Component extends SvelteComponent]
591
637
```
592
638
639
+ Types for Svelte are broken.
640
+ Raise it with Svelte.
641
+
593
642
### Example: Vue
594
643
595
644
> 👉 ** Note** : you must set ` elementAttributeNameCase: 'html' ` for Vue.
@@ -600,7 +649,7 @@ In Node.js, do:
600
649
import serverRenderer from ' @vue/server-renderer'
601
650
import {h } from ' hastscript'
602
651
import {toJsxRuntime } from ' hast-util-to-jsx-runtime'
603
- import {Fragment , jsx , jsxs } from ' vue/jsx-runtime' // Available since `vue@^ 3.3.0-alpha.6 `.
652
+ import {
Fragment ,
jsx ,
jsxs }
from ' vue/jsx-runtime' // Available since `[email protected] `.
604
653
605
654
console .log (
606
655
await serverRenderer .renderToString (
@@ -640,6 +689,21 @@ function Component() {
640
689
}
641
690
```
642
691
692
+ To add proper type support,
693
+ register a global JSX namespace:
694
+
695
+ ``` ts
696
+ import type {JSX as Jsx } from ' vue/jsx-runtime'
697
+
698
+ declare global {
699
+ namespace JSX {
700
+ type ElementClass = Jsx .ElementClass
701
+ type Element = Jsx .Element
702
+ type IntrinsicElements = Jsx .IntrinsicElements
703
+ }
704
+ }
705
+ ```
706
+
643
707
## Syntax
644
708
645
709
HTML is parsed according to WHATWG HTML (the living standard), which is also
@@ -653,7 +717,7 @@ versions of Node.js.
653
717
When we cut a new major release, we drop support for unmaintained versions of
654
718
Node.
655
719
This means we try to keep the current release line,
656
- ` hast-util-to-jsx-runtime@^ 2 ` , compatible with Node.js 16.
720
+ ` hast-util-to-jsx-runtime@2 ` , compatible with Node.js 16.
657
721
658
722
## Security
659
723
0 commit comments