Skip to content

More Rich Type on Data & VNodeProps for Render Function #2248

@ci010

Description

@ci010

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
}

Activity

posva

posva commented on Sep 29, 2020

@posva
Member

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

locked and limited conversation to collaborators on Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @posva@ci010

        Issue actions

          More Rich Type on Data & VNodeProps for Render Function · Issue #2248 · vuejs/core