omi icon indicating copy to clipboard operation
omi copied to clipboard

TS: Is there a way to automatically generate the attributes type of a custom element?

Open xcatliu opened this issue 5 years ago • 1 comments

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

xcatliu avatar Oct 23 '18 15:10 xcatliu

https://github.com/ionic-team/stencil

xcatliu avatar Sep 23 '19 12:09 xcatliu