|
1 | 1 | import type {HProperties, HChild, HResult} from './core.js' |
2 | 2 |
|
3 | | -export namespace JSX { |
4 | | - /** |
5 | | - * This defines the return value of JSX syntax. |
6 | | - */ |
7 | | - type Element = HResult |
| 3 | +declare global { |
| 4 | + namespace JSX { |
| 5 | + /** |
| 6 | + * This defines the return value of JSX syntax. |
| 7 | + */ |
| 8 | + type Element = HResult |
8 | 9 |
|
9 | | - /** |
10 | | - * This disallows the use of functional components. |
11 | | - */ |
12 | | - type IntrinsicAttributes = never |
| 10 | + /** |
| 11 | + * This disallows the use of functional components. |
| 12 | + */ |
| 13 | + // type IntrinsicAttributes = never |
13 | 14 |
|
14 | | - /** |
15 | | - * This defines the prop types for known elements. |
16 | | - * |
17 | | - * For `hastscript` this defines any string may be used in combination with `hast` `Properties`. |
18 | | - * |
19 | | - * This **must** be an interface. |
20 | | - */ |
21 | | - // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style, @typescript-eslint/consistent-type-definitions |
22 | | - interface IntrinsicElements { |
23 | | - [name: string]: |
24 | | - | HProperties |
25 | | - | { |
| 15 | + /** |
| 16 | + * This defines the prop types for known elements. |
| 17 | + * |
| 18 | + * For `hastscript` this defines any string may be used in combination with `hast` `Properties`. |
| 19 | + * |
| 20 | + * This **must** be an interface. |
| 21 | + */ |
| 22 | + // eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style, @typescript-eslint/consistent-type-definitions |
| 23 | + interface IntrinsicElements { |
| 24 | + [name: string]: |
| 25 | + | HProperties |
| 26 | + | { |
26 | 27 | /** |
27 | 28 | * The prop that matches `ElementChildrenAttribute` key defines the type of JSX children, defines the children type. |
28 | 29 | */ |
29 | 30 | children?: HChild |
30 | 31 | } |
31 | | - } |
| 32 | + } |
32 | 33 |
|
33 | | - /** |
34 | | - * The key of this interface defines as what prop children are passed. |
35 | | - */ |
36 | | - // eslint-disable-next-line @typescript-eslint/consistent-type-definitions |
37 | | - interface ElementChildrenAttribute { |
38 | 34 | /** |
39 | | - * Only the key matters, not the value. |
| 35 | + * The key of this interface defines as what prop children are passed. |
40 | 36 | */ |
41 | | - children?: never |
| 37 | + // eslint-disable-next-line @typescript-eslint/consistent-type-definitions |
| 38 | + interface ElementChildrenAttribute { |
| 39 | + /** |
| 40 | + * Only the key matters, not the value. |
| 41 | + */ |
| 42 | + //TODO: is there a way to make this work? |
| 43 | + // currently fails with the following error when including `{children}` |
| 44 | + // -> error TS2322: Type 'HChild' is not assignable to type 'Node | HPrimitiveChild'. |
| 45 | + children?: HChild |
| 46 | + } |
42 | 47 | } |
43 | 48 | } |
0 commit comments