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

No intellisense for props, slots etc. with v4 #5903

Closed
Sector6759 opened this issue Jun 16, 2024 · 26 comments · May be fixed by jjlim7/tournament-management-system#42 or jjlim7/tournament-management-system#43
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@Sector6759
Copy link

Sector6759 commented Jun 16, 2024

Describe the bug

In v4, it seems like some types are not defined correctly as I'm getting no Intellisense for props, slots etc.

I see that you used to extend ClassComponent before v4

declare class Button extends ClassComponent<ButtonProps, ButtonSlots, ButtonEmits> {}

Now in v4 you use DefineComponent

declare const Button: DefineComponent<ButtonProps, ButtonSlots, ButtonEmits>;

It seems like something is still missing somewhere in the type parameter chain.

Intellisense in v3
image
Intellisense in v4
image

Reproducer

StackBlitz

Edit: this reproducer now shows the desired behavior because I updated it according to my comment.

PrimeVue version

4

Vue version

3.x

Language

TypeScript

Build / Runtime

Vue CLI App

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@Sector6759 Sector6759 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jun 16, 2024
@nawazishali
Copy link

Facing the same issue with Nuxt 3.

@mertsincan
Copy link
Member

Thanks a lot for your report! @Sector6759, is there a small sample project with your config to replicate it?

@mertsincan mertsincan self-assigned this Jun 17, 2024
@mertsincan mertsincan added Status: Pending Review Issue or pull request is being reviewed by Core Team and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jun 17, 2024
@mertsincan mertsincan added this to the 4.x milestone Jun 17, 2024
@Sector6759
Copy link
Author

Sector6759 commented Jun 18, 2024

@mertsincan I added a reproducer link in my original post. Don't forget to accept the prompt on StackBlitz when it asks to install the Vue - Official extension.

@matt-sr
Copy link

matt-sr commented Jun 28, 2024

Hi, I also have no Intellisense for props - only the documentation comments, with Typescript and without. Vite project, installed following Vite instructions, in styled mode. Should be pretty easy to repro, as I made the project yesterday - version 4.0.0-rc.2

@tomascf
Copy link

tomascf commented Jul 2, 2024

Also encountering the same issue with Nuxt 3

@Fischer96
Copy link

Yep same issue in all editors I use

@Sector6759
Copy link
Author

@mertsincan What exactly is the 4.x milestone? There are a lot of issues which have been opened a "long" time ago. Also, there isn't a single closed issue related to this milestone. Is this merely for collecting issues that will eventually be moved to more specific milestones?

@Proxx07
Copy link

Proxx07 commented Jul 8, 2024

Also some components doesn't have any intellisense for their props
img

@2234839
Copy link
Contributor

2234839 commented Jul 17, 2024

My project also has this problem, vscode has no relevant type hints at all
图片

@2234839
Copy link
Contributor

2234839 commented Jul 17, 2024

I just have created a new test project at https://github.com/2234839/primevue-test
images
Also unable to get the correct type tips, I use Vue.volar plugin
vscode information is as follows:
Version: 1.91.1 (user setup)
Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729
Date: 2024-07-09T22:06:49.809Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.22631

@2234839
Copy link
Contributor

2234839 commented Jul 21, 2024

图片
I've found that the Tree component gets good type hints, and I hope it helps to improve other components

@2234839
Copy link
Contributor

2234839 commented Jul 21, 2024

One problem I found was that when I referenced a component in a vue file using the form 'import Tree from' primevue/tree ', I Ctrl-clicked the component and it jumped to 'declare const Tree'. This type of situation is not good
图片

When I don't have in vue file references, I use CTRL click components will jump to Tree: GlobalComponentConstructor < TreeProps TreeSlots, TreeEmits >, type hinting at this time is perfect
图片

@2234839
Copy link
Contributor

2234839 commented Jul 21, 2024

replace declare const Tree: DefineComponent<TreeProps, TreeSlots, TreeEmits>; To declare a const Tree: GlobalComponentConstructor < TreeProps TreeSlots, TreeEmits >; can get type hints when you use import. What's the difference between the two methods
@mertsincan

图片

2234839 added a commit to 2234839/primevue that referenced this issue Jul 21, 2024
@2234839 2234839 mentioned this issue Jul 21, 2024
@Sector6759
Copy link
Author

@nawazishali @matt-sr @tomascf @Fischer96 @Proxx07 @2234839

I recently noticed that I wasn't importing PrimeVue components like intended. I always imported the PrimeVue components in my own components, like I did in the example picture, but the docs never say that we should do so. Instead they instruct us to register components, by using app.component(). To make PrimeVue v4 work, we also need to install the PrimeVue plugin with app.use(). After removing the import statement in my own component, intellisense now works as expected. By the way, this was already the intended way in v3 (register, plugin), but indeed some things behave differently in v4 compared to v3, because in v3, importing a component like I did in my example did not break intellisense.

@mertsincan I'm not sure if this issue can be closed. I assume something's still off, because I don't expect intellisense to break only because of importing PrimeVue components inside my own components.

@rogrile
Copy link

rogrile commented Aug 4, 2024

Same issue here, would love to get back to primevue, but without intellisense the dev time will definitely increase

@Sector6759
Copy link
Author

@rogrile Did you even read my last comment?

@rogrile
Copy link

rogrile commented Aug 4, 2024

I'm using Nuxt (with a nuxt module for primevue). I have autoimports on, thus I do not import the components myself, nor do I use app.component() or app.use() for plugins. This does not work out of the box, and it does work with primevue 3

@Sector6759
Copy link
Author

I see. I'd like to get an update on this from the PrimeVue team myself. My only guess is that they are busy fixing all kinds of things.

@pwang2
Copy link

pwang2 commented Aug 6, 2024

I can resolve my case with workaround from @Sector6759 mentioned above. Thanks for the information.

TLDR: If we've already imported primevue using the app.use in main.ts, when we import the component again as local Components in SFC, the code IntelliSense will be messed up.

Even it might be handy, I am strongly not in favor of using a global registration. Not to mention code actions usually import the component to local imports as we type automatically. Hope we can hear back from PrimeVue team soon.

@Sector6759
Copy link
Author

@pwang2 Alternatively you can use auto imports.

@pwang2
Copy link

pwang2 commented Aug 6, 2024

@pwang2 Alternatively you can use auto imports.

Thanks. Yes. I keep thinking about from a modular even with SFC. So, I am feeling sort of mixed when using something not imported. I could be wrong/stubborn here. as defineProps/defineEmits macro stuff also make the code we author different than what we wrote.

@Eirmas
Copy link

Eirmas commented Sep 26, 2024

Here is a temporary fix that I did using the PrimeVue auto-import plugin

  1. Enable auto import as described here: https://primevue.org/autoimport/
  2. Use dts: false in the options to disable overrides.
  3. Create a components.d.ts file. Put it in your src directory or make sure it's part of the TypeScript compilation
// components.d.ts
import { DefineComponent, GlobalComponentConstructor } from '@primevue/core';

type FixPrimeVue<T> =
  T extends DefineComponent<infer Props, infer Slots, infer Emits, infer Methods>
    ? GlobalComponentConstructor<Props, Slots, Emits, Methods>
    : T;

declare module 'vue' {
  export interface GlobalComponents {
    Button: FixPrimeVue<typeof import('primevue/button')['default']>
    // Add the components you are using here
  }
}

Hopefully #6088 is merged soon which should fix this.

@tugcekucukoglu tugcekucukoglu modified the milestones: 4.x, 4.1.1 Oct 11, 2024
@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Oct 11, 2024
@Skstud5
Copy link

Skstud5 commented Nov 1, 2024

I encountered the same problem. Absolutely clean project, PrimeVue version 4.1.1, however, this IntelliSense does not work in WebStorm
image

but works in VScode
image

@Sector6759
Copy link
Author

@Skstud5 Are you sure you have set up WebStorm correctly? I just tried it in WebStorm and it does work.
Check if you have set a Node.js interpreter under File | Settings | Languages & Frameworks | Node.js

@Skstud5
Copy link

Skstud5 commented Nov 1, 2024

Yes, everything is set up.
I will try on Saturday or Sunday, I will try to repeat this again. What will happen in the end - I will write here

@Sector6759
Copy link
Author

@Skstud5 Just follow this up-to-date Getting started tutorial which the PrimeVue team uploaded recently. If intellisense is not working in WebStorm for you, then there has to be something wrong with your setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet