Subscribe on changes!

More Rich Type on Data & VNodeProps for Render Function

avatar
Sep 27th 2020

What problem does this feature solve?

The current render function h props param is slightly different than vue2, described in https://v3.vuejs.org/guide/migration/render-function-api.html#vnode-props-format.

Though, the current type on h's prop param is Data & VNodeProps. Neither of them has the similar type definition like VNodeData in vue2, declaring the class, style, staticClass, etc. (only the Record<string, unknown> currently)

Adding some basic typing on it can helps user to migrate faster and avoid passing param like vue2.

What does the proposed API look like?

The API props param type changed, at least including some basic definition like

{
    staticClass?: string;
    class?: string | string[];
    staticStyle?: { [key: string]: any };
    style?: string | object[] | object;
    onClick?: (e: MouseEvent) => void
    ... rest of definitions
}
avatar
Sep 29th 2020

I don't think there is a way, only using types, that allows both, to hint the user about removed attributes and, to allow users to use their own props on the new flattened structure. I think it's worth updating the docs so I opened a PR there