Skip to content

non defined props in functional components are empty #5469

@enpitsuLin

Description

@enpitsuLin

Version

3.2.25

Reproduction link

codesandbox.io

Steps to reproduce

See reproduction link

What is expected?

Both components Test1 and Test2 behave consistently

What is actually happening?

The Test1 component is written in such a way that the props defined by the generic parameters are missing(BTW my IDE code hints work fine), in fact the option of the component has no props option, and the additional definition of props like the following will make it work correctly.

import { defineComponent, ref } from "vue";

const HelloWorld = defineComponent<{ msg: string }>(({ msg }) => {
  // some code
});

HelloWorld.props = { msg: { type: String } };

export default HelloWorld;

Does this mean that defineComponent requires adding additional options such as props? Or is this a working feature?


I just want to make it easier to use JSX instead of SFC, and more functional, maybe there are some compile-time plugins here that can make this write work for me?

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

    Issue actions