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

types(runtime-core): add h function overload #9756

Merged
merged 7 commits into from
Dec 11, 2023
Merged
17 changes: 17 additions & 0 deletions packages/runtime-core/src/h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,24 @@ interface Constructor<P = any> {
// The following is a series of overloads for providing props validation of
// manually written render functions.

type HTMLElementEventHandler = {
[K in keyof HTMLElementEventMap as `on${Capitalize<K>}`]?: (
ev: HTMLElementEventMap[K]
) => any
}

// element
export function h<K extends keyof HTMLElementTagNameMap>(
type: K,
children?: RawChildren
): VNode
export function h<K extends keyof HTMLElementTagNameMap>(
type: K,
props?: (RawProps & HTMLElementEventHandler) | null,
children?: RawChildren | RawSlots
): VNode

// custom element
export function h(type: string, children?: RawChildren): VNode
export function h(
type: string,
Expand Down