Add these codes in vue-next/packages/runtime-dom/types/jsx.d.ts
import {
VNode,
VNodeArrayChildren,
VNodeProps,
ComponentInternalInstance,
} from '@vue/runtime-core';
declare module 'vue' {
// copy from @vue/runtime-core
type RawChildren =
| string
| number
| boolean
| VNode
| VNodeArrayChildren
| (() => any);
// copy from @vue/runtime-core
type RawProps = VNodeProps & {
__v_isVNode?: never;
[Symbol.iterator]?: never;
};
// copy from @vue/runtime-core
type RawSlots = {
[name: string]: unknown;
$stable?: boolean;
_ctx?: ComponentInternalInstance | null;
_?: 1;
};
export function h<K extends StringKeyOf<IntrinsicElementAttributes>>(
type: K ,
props?: RawProps & ElementAttrs<
IntrinsicElementAttributes[K]
> | null,
children?: RawChildren | RawSlots
): VNode;
}
These codes will help us to do type checking with @vuedx/typecheck
Another Question: What help does @vuedx need? It seems that its development has stoped for several weeks.
@xiaoxiangmoe is this still relevant? There have been significant changes been done to jsx.d.ts, so can you please respond wether this issue is still actionable or can be closed?
Thanks!
this issue is still actionable.
See example:
import { h } from 'vue'
// @ts-expect-error Parameter 'event' implicitly has an 'any' type.ts(7006)
export default h('button',{ onClick: event => { console.log(event) } })
Thanks
Now, I'm not using h in TS plugin but I'll confirm if this affects JSX or not.
@znck Could you sharing us the reason why not using h in TS plugin. Thank you.
Template is converted to TSX so h is not required for type checking.
Most helpful comment
this issue is still actionable.
See example: