Skip to content

Commit 0f73f39

Browse files
authored
fix(types/jsx): jsx-runtime types for global JSX namespace registration (#7978)
1 parent 77686cf commit 0f73f39

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

packages/vue/jsx.d.ts

+30-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,36 @@
11
// global JSX namespace registration
2-
import { JSX as JSXInternal } from './jsx-runtime'
2+
// somehow we have to copy=pase the jsx-runtime types here to make TypeScript happy
3+
import { VNode, VNodeRef } from '@vue/runtime-dom'
4+
import { IntrinsicElementAttributes } from './jsx-runtime/dom'
5+
6+
export * from './jsx-runtime/dom'
7+
8+
export type ReservedProps = {
9+
key?: string | number | symbol
10+
ref?: VNodeRef
11+
ref_for?: boolean
12+
ref_key?: string
13+
}
14+
15+
export type NativeElements = {
16+
[K in keyof IntrinsicElementAttributes]: IntrinsicElementAttributes[K] &
17+
ReservedProps
18+
}
319

420
declare global {
521
namespace JSX {
6-
interface Element extends JSXInternal.Element {}
7-
interface ElementClass extends JSXInternal.ElementClass {}
8-
interface ElementAttributesProperty
9-
extends JSXInternal.ElementAttributesProperty {}
10-
interface IntrinsicElements extends JSXInternal.IntrinsicElements {}
11-
interface IntrinsicAttributes extends JSXInternal.IntrinsicAttributes {}
22+
export interface Element extends VNode {}
23+
export interface ElementClass {
24+
$props: {}
25+
}
26+
export interface ElementAttributesProperty {
27+
$props: {}
28+
}
29+
export interface IntrinsicElements extends NativeElements {
30+
// allow arbitrary elements
31+
// @ts-ignore suppress ts:2374 = Duplicate string index signature.
32+
[name: string]: any
33+
}
34+
export interface IntrinsicAttributes extends ReservedProps {}
1235
}
1336
}
14-
15-
export {}

packages/vue/types/jsx-register.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
// imports the global JSX namespace registration for compat.
33
// TODO: remove in 3.4
44
import '../jsx'
5+
6+
export * from '../jsx-runtime/dom'

0 commit comments

Comments
 (0)