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

Generic Prop Type is incompatible with defineModel and Typed Slots #3179

Closed
sxzz opened this issue May 12, 2023 · 4 comments
Closed

Generic Prop Type is incompatible with defineModel and Typed Slots #3179

sxzz opened this issue May 12, 2023 · 4 comments
Labels
duplicate This issue or pull request already exists good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@sxzz
Copy link
Member

sxzz commented May 12, 2023

Reproduction: https://github.com/artsmp0/vue-generic-type-bug

See src/components/HelloWorld.vue and src/components/model-with-props-bug.vue.

@xiaoxiangmoe xiaoxiangmoe added the enhancement New feature or request label May 16, 2023
@so1ve
Copy link
Member

so1ve commented May 17, 2023

Found a bug here:

It seems to be buggy here 👆

If we add a type assertion

It works perfectly.

@so1ve
Copy link
Member

so1ve commented May 21, 2023

Hi @pikax, could you please confirm if it is a vue core issue? The BooleanKey type does not play well with generics.

@pikax
Copy link
Member

pikax commented May 21, 2023

BooleanKey does not play nicely with generics as you can see the fix to work with withDefault was to remove that https://github.com/vuejs/core/pull/8335/files

For me (not that familiar with Language Tools) this is a bug with Language tools looking at the generated code (after update the dependencies):

// 当使用 defineModel 时,在模板中访问 msg 报错
const count = defineModel<number>("count", {
  local: true,
  default: 999,
});
const __VLS_publicComponent = (await import('vue')).defineComponent({
props: {} as { 
"count": import('vue').PropType<number>,
},
props: ({} as __VLS_TypePropsToRuntimeProps<typeof __VLS_props>),
setup() {
return {
};
},
});

props is declared twice instead of merged in.

@johnsoncodehk
Copy link
Member

Duplicate of #3164

@johnsoncodehk johnsoncodehk marked this as a duplicate of #3164 Jun 8, 2023
@johnsoncodehk johnsoncodehk closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2023
@johnsoncodehk johnsoncodehk added duplicate This issue or pull request already exists good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first and removed enhancement New feature or request labels Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

No branches or pull requests

5 participants