-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
non defined props in functional components are empty #5469
Comments
The bug is that props should contain the attrs when no props option is defined. As a workaround, define the props option |
@posva that only applies to functional components, doesn't it? Vue requires runtime props options from which prop types are inferred. It's currently not possible to define a (stateful) component without runtime props and then provide prop types via the generic argument. I started a discussion some Time ago, @pikax also wrote a small proposal about how to support this in the RFCs repo I think, but so gar it went nowhere. |
Is it really a bug @posva? I've never used defineComponent, but it looks to me like it's just a helper function for defining a stateful components (with type inference) and those requires props to be declared upfront. Not sure why author mentioned functional component here. I think with TypeScript it's better to use script-setup and defineProps which will generate runtime props definition for you. https://vuejs.org/guide/typescript/composition-api.html#typing-component-props |
@sqal script-setup are excellent, but I can't use both render function and script-setup |
It's not a bug, I somehow read a functional component but it's was a regular one... This is indeed expected for stateful components |
Version
3.2.25
Reproduction link
codesandbox.io
Steps to reproduce
See reproduction link
What is expected?
Both components
Test1
andTest2
behave consistentlyWhat 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 ofprops
like the following will make it work correctly.Does this mean that defineComponent requires adding additional
options
such asprops
? 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?
The text was updated successfully, but these errors were encountered: