Skip to content

Commit 0fa0bc8

Browse files
johnjenkinsJohn Jenkins
andauthored
fix(types): add IntrinsicElements to jsximportSource runtime definitions (#6532)
* fix(runtime): fix jsxImportSource Fragment handling * chore: * fix(types): add IntrinsicElements to jsximportSource runtime definitions --------- Co-authored-by: John Jenkins <john.jenkins@nanoporetech.com>
1 parent 953346e commit 0fa0bc8

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

src/internal/stencil-core/jsx-dev-runtime.d.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* TypeScript will automatically import from this module in development mode.
77
*/
88

9-
import type { VNode } from '../stencil-public-runtime';
9+
import type { VNode, JSXBase } from '../stencil-public-runtime';
10+
import type { JSX as LocalJSX } from '../stencil-public-runtime';
1011

1112
export { Fragment } from '../stencil-public-runtime';
1213

@@ -21,3 +22,20 @@ export function jsxDEV(
2122
source?: any,
2223
self?: any,
2324
): VNode;
25+
26+
/**
27+
* JSX namespace for TypeScript's automatic JSX runtime.
28+
* This is required for TypeScript to resolve JSX element types when using
29+
* "jsx": "react-jsxdev" with "jsxImportSource": "@stencil/core".
30+
*/
31+
export namespace JSX {
32+
type BaseElements = LocalJSX.IntrinsicElements & JSXBase.IntrinsicElements;
33+
34+
export type IntrinsicElements = {
35+
[K in keyof BaseElements]: BaseElements[K] & { children?: any };
36+
} & {
37+
[tagName: string]: any;
38+
};
39+
40+
export type Element = VNode | VNode[] | null;
41+
}

src/internal/stencil-core/jsx-runtime.d.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* these modules instead of requiring manual `h` imports.
88
*/
99

10-
import type { VNode } from '../stencil-public-runtime';
10+
import type { VNode, JSXBase } from '../stencil-public-runtime';
11+
import type { JSX as LocalJSX } from '../stencil-public-runtime';
1112

1213
export { Fragment } from '../stencil-public-runtime';
1314

@@ -20,3 +21,20 @@ export function jsx(type: any, props: any, key?: string): VNode;
2021
* JSX runtime function for creating elements with static children.
2122
*/
2223
export function jsxs(type: any, props: any, key?: string): VNode;
24+
25+
/**
26+
+ * JSX namespace for TypeScript's automatic JSX runtime.
27+
+ * This is required for TypeScript to resolve JSX element types when using
28+
+ * "jsx": "react-jsx" with "jsxImportSource": "@stencil/core".
29+
+ */
30+
export namespace JSX {
31+
type BaseElements = LocalJSX.IntrinsicElements & JSXBase.IntrinsicElements;
32+
33+
export type IntrinsicElements = {
34+
[K in keyof BaseElements]: BaseElements[K] & { children?: any };
35+
} & {
36+
[tagName: string]: any;
37+
};
38+
39+
export type Element = VNode | VNode[] | null;
40+
}

0 commit comments

Comments
 (0)