Open ccqgithub opened 1 month ago
For problem 1, when I change DefineComponent
from @primevue/core
to vue
, the problem fixed.
import type { DefineComponent } from '@primevue/core';
declare const Button: DefineComponent<ButtonProps, ButtonSlots, ButtonEmits>;
to
import type { DefineComponent } from 'vue';
declare const Button: DefineComponent<ButtonProps, ButtonSlots, ButtonEmits>;
For problem 1, when I change
DefineComponent
from@primevue/core
tovue
, the problem fixed.import type { DefineComponent } from '@primevue/core'; declare const Button: DefineComponent<ButtonProps, ButtonSlots, ButtonEmits>;
to
import type { DefineComponent } from 'vue'; declare const Button: DefineComponent<ButtonProps, ButtonSlots, ButtonEmits>;
Do this you fix only for props. Slots and emits doesn't work anyway.
I found what vue DefineComponent typescript type uses first generic (which is ButtonProps in this case) for another type guards. So, i think fix this issue is replace in @primevue/core type guard DefineComponent
:
from https://github.com/primefaces/primevue/blob/bda04bef756cbcb15271116a1718bcefceb83747/packages/core/src/index.d.ts#L17
to:
export type DefineComponent<P = {}, S = {}, E = {}, M = {}> = _DefineComponent<P, {}, {}, {}, M & MethodOptions, {}, {}, E & ObjectEmitsOptions, string, PublicProps, Readonly<ExtractPropTypes<P>>, ExtractDefaultPropTypes<P>, SlotsType<S>>;
It require types PublicProps, SlotsType, ExtractDefaultPropTypes, ExtractPropTypes
from vue bundle
But i think need to use defineComponent (from primevue team side) in vue files by vue's typescript guide: https://vuejs.org/guide/typescript/overview#definecomponent
Describe the bug
(Vscode with Volar)
There are no type hinting for this.
But this is ok.
When I import components, it will load the following global type declaration, which will pollute other component's types.
For example, when I import
Button
ofprimeVue
, the otherButton
in template that not import fromprimevue
will be polluted.Reproducer
https://stackblitz.com/edit/primevue-4-ts-vite-issue-template-j7eglm?file=src%2FApp.vue
PrimeVue version
4.0.0
Vue version
3.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
No response
Steps to reproduce the behavior
No response
Expected behavior
No response