Skip to content
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

typing defineComponent props #3796

Zclhlmgqzc opened this issue May 19, 2021 · 4 comments · Fixed by #5416

typing defineComponent props #3796

Zclhlmgqzc opened this issue May 19, 2021 · 4 comments · Fixed by #5416


Copy link

Zclhlmgqzc commented May 19, 2021



Reproduction link


Steps to reproduce

import { NavBar } from 'vant'
import { defineComponent, h } from 'vue'

export default defineComponent({
  name: 'MyNavBar',
  props: { 
    // more props ...
  setup(props, { attrs, slots }) {
    return ()  => h(
(JSX attribute) title?: string | undefined
<van-nav-bar title={} />

but my-nav-bar title type lost
<my-nav-bar title={} />

What is expected?

(JSX attribute) title?: string | undefined
<my-nav-bar title={} />


` B~M492 30T2AC$TJ4 }24

What is actually happening?

my-nav-bar title type lost
<my-nav-bar title={} />
Copy link

posva commented May 19, 2021

You might want to open a PR. But you will need to explain yourself (in English) Ines off just post pictures

@posva posva closed this as completed May 19, 2021
Copy link
Contributor Author

@posva I added some background information

Copy link

chenjiahan commented Jun 1, 2021

@posva @pikax The type of Component.props is missing after wrapping the defineComponent method, which makes it difficult to create HOC.

import { defineComponent } from 'vue';

const Component1 = {
  props: {
    foo: String,

const Component2 = defineComponent(Component1);

Component1.props; // --> { foo: StringConstructor }
Component2.props; // --> any

iwusong pushed a commit to iwusong/core that referenced this issue May 13, 2022
yyx990803 added a commit that referenced this issue May 20, 2022
This is necessary for compatibility w/ tsc-generated component types
using DefineComponent.

revert #5416
reopen #3796
fix #5967
@yyx990803 yyx990803 reopened this May 20, 2022
Copy link

yyx990803 commented May 20, 2022

#5416 introduced a regression because it changed the argument order of DefineComponent, which breaks component definitions generated via tsc/vue-tsc, and a number of other cases.

We need to find a way to do it while preserving the current argument order of DefineComponent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
5 participants