Open
Description
🧐 Problem Description
As mentioned here, I'd like to have type safety for custom directives when using Vue 3 and JSX + Typescript (TSX).
💻 Sample code
import { defineCustomElement } from "vue";
import ClickOutside from "click-outside-vue3";
export default defineCustomElement({
name: "Hello",
directives: {
clickOutside: ClickOutside.directive,
},
render() {
return <div vClickOutside={() => console.log("clicked outside")}></div>;
},
});
🚑 Other information
It works, but gives an annoying type error, saying:
Type '{ vClickOutside: () => void; }' is not assignable to type 'ElementAttrs<HTMLAttributes>'.
Property 'vClickOutside' does not exist on type 'ElementAttrs<HTMLAttributes>'.ts(2322)
The current workaround that I applied is to use @ts-ignore
(not that vite
won't build it otherwise, but just to make the red line go away in VS Code), I didn't have time to figure out which interface I have to augment, potentially even patching node_modules using patch-package