Skip to content
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

fix: copy-paste jsx-runtime types for global JSX namespace registration #7978

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions packages/vue/jsx.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
// global JSX namespace registration
import { JSX as JSXInternal } from './jsx-runtime'
// somehow we have to copy=pase the jsx-runtime types here to make TypeScript happy
import { VNode, VNodeRef } from '@vue/runtime-dom'
import { IntrinsicElementAttributes } from './jsx-runtime/dom'

export * from './jsx-runtime/dom'

export type ReservedProps = {
key?: string | number | symbol
ref?: VNodeRef
ref_for?: boolean
ref_key?: string
}

export type NativeElements = {
[K in keyof IntrinsicElementAttributes]: IntrinsicElementAttributes[K] &
ReservedProps
}

declare global {
namespace JSX {
interface Element extends JSXInternal.Element {}
interface ElementClass extends JSXInternal.ElementClass {}
interface ElementAttributesProperty
extends JSXInternal.ElementAttributesProperty {}
interface IntrinsicElements extends JSXInternal.IntrinsicElements {}
interface IntrinsicAttributes extends JSXInternal.IntrinsicAttributes {}
export interface Element extends VNode {}
export interface ElementClass {
$props: {}
}
export interface ElementAttributesProperty {
$props: {}
}
export interface IntrinsicElements extends NativeElements {
// allow arbitrary elements
// @ts-ignore suppress ts:2374 = Duplicate string index signature.
[name: string]: any
}
export interface IntrinsicAttributes extends ReservedProps {}
}
}

export {}
2 changes: 2 additions & 0 deletions packages/vue/types/jsx-register.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
// imports the global JSX namespace registration for compat.
// TODO: remove in 3.4
import '../jsx'

export * from '../jsx-runtime/dom'