omi
omi copied to clipboard
TS: Is there a way to automatically generate the attributes type of a custom element?
Currently we need to write the attributes type manually like this:
// This is the only way to set the attributes type of a custom element
// @TODO @xcatliu We are working on a tool to build the type definition automatically
//
// https://github.com/Microsoft/TypeScript/issues/4648
declare global {
namespace JSX {
interface IntrinsicElements {
'hello-omi': Omi.CustomElementBaseAttributes & {
msg: string;
'prop-from-parent': string;
onAbc: (e: Event) => void;
};
}
}
}
We need a tool to build the type definition automatically
https://github.com/ionic-team/stencil