Add (all) imports (typescript, phpstorm 2024.2.3)

Hi!

I am very frustrated about how to add imports all the time. this could be much more efficient than it currently is!

One by one:

Tooltip shows EsLint-Errors/Quickfixes instead of suggesting Imports

Quickfix shows different import actions unsorted:

Unambiguous imports on the fly:

This option seems not to work 100%. Some imports were added, others unambiguous imports not

Add all imports:

Dont work as well and behaves even differently than “Unambiguous imports on the fly”-option.

 

Is there something else i can do?

 

I would suggest an action “add all imports” which either works (if unambiguous) or propmts the user with decisions for each import with a built in code preview window and the most-likely import suggestions - something like that. something which makes sense and easy to work with. with the last decision made the popup closes without extra click on ok (optional) to reduce unwanted extra steps even more. action → decision(s) → done.

---

PhpStorm 2024.2.3
Build #PS-242.23339.16, built on September 25, 2024
 

0
8 comments
Hello,
I am sorry to hear about your bad experience with the IDE. 
If auto-imports are not suggested in the tooltip, it may mean that the IDE did not find a corresponding file/module to import from. To better understand what caused this behavior, we need to replicate it on our side. Could you please share a small example where this issue is reproduced? 

In the QuickFixes section, we display suggestions from the IDE(at the top of the list) and from the TypeScript service(with the TS icon at the bottom of the list). 

Regarding the unambiguous imports: unfortunately, again it is difficult to determine why the option did not work in your particular case. With a more detailed description of the case or a sample project, we would be in a better position to determine what caused the problem.
0

, it may mean that the IDE did not find a corresponding file/module to import from.

no, all imports can be resolved and they will be suggested in the quickfix, but not in the main tooltip, because eslint will be prioritized 

 

Example-Project

https://github.com/comod/intellij-import-issue/blob/main/src/server/queries.ts

 

0
Thank you for the example. I reproduced the problem with the quick fixes in the tooltip and created a separate public thread for it: https://youtrack.jetbrains.com/issue/WEB-69660. Please follow it for updates. 
However, regarding the 'Unambiguous imports on the fly', I was not able to replicate this issue. Please refer to the attached video. Could you please demonstrate the exact steps?
0

i do simply uncomment the imports and wait for the auto imports. i cant reproduce it neither anymore. if i have a scenario again i will let you know, but it seems to lack at some point…

What do you think about the other points? If there are ambiguous imports the ide do not help a lot and you need to import by using these tooltips or a combination of shortcuts. as i suggested this could be improved.

 

0
Hello Michael, 
>What do you think about the other points?

Could you please clarify what exact point you are referring to? I created an issue for the problem with tooltips and unambitious imports seem to work correctly(as I demonstrated in the video). Could you please clarify what other point I am missing?
0

Hi!

i cant see a video, only screenshots in the ticket. 

summary:

  • [DONE] Tooltip shows EsLint-Errors/Quickfixes instead of suggesting Imports
    • => Ticket created
  • Quickfix shows different import-actions unsorted
    • See above
  • [DONE] Unambiguous imports on the fly
    • Cant reproduced. But there is definitively something not right, as described in my example repo (see uncommented imports with comments!)
  • "Add all imports"/"Optimize imports"-Action as improved popup
    • This is a suggestion how to improve the IDE - as describe above - 

       

I hope its clearer now.


 


 

0

one more issue:

Optimize Imports do “nothing” (See tooltip “Imports optimized”)…

…but i can do it via Quickfix: 

 

 

Do you aggree that this is far way from a good user expirience? 

 

0
Thank you for the clarification. 
1. There are suggestions from the IDE and from the TS service. The latest are always placed in the end of the list, so this is expected. However, for the IDE suggestions I created a usability issue: https://youtrack.jetbrains.com/issue/WEB-69774. 

2. Could you please create a separate feature request and describe your suggestions there: https://youtrack.jetbrains.com/issues/WEB. We will collect users feedback in this issue. 

3. Regarding the latest screenshots, as far as I understand, they are not from the example that you shared earlier. Could you please attach a sample where the problem is reproduced?
0

Please sign in to leave a comment.