-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Missing auto import suggestions for UMD modules such as classnames
#41761
Comments
Would someone guide me how I can easily get to a point to reproduce this locally?
Found how to work with completions in |
Update: the comment above only happens if the file extension is |
@OliverJAsh is the issue occurs within Ya I can finally reproduce this constantly. As you mentioned it's related to CommonJS module as they have the following export declaration declare const someModule: () => void;
export = someModule; |
I think I only tested it with |
@OliverJAsh would you also provide a simplified version of your TS config? specially how you configured the modules. there are settings that I'm interested to see: |
To be honest at this point I'm not sure if this is a bug or the correct behaviour. The code fix works though I'm not sure if auto import should be provided or even how auto import works in TypeScript/VSCode. I would need some help to investigate more. Added a new fourslash test here: |
@aminpaks I am using the default settings as I have no |
@OliverJAsh yes this is exactly what I observed by looking at the code and writing that unit-test. Here I'm not sure if auto import should (if yes what is the default behaviour) be provided when you complete writing |
Most users nowadays choose to import UMD modules rather than relying on the globals provided by the UMD (that's the best practice now) so I think the majority of users would find this useful. Just to make sure we're on the same page, this is what I'm asking for: the import should be suggested in the list as the user types, in the same way that all other non-UMD modules appear in the list. |
@OliverJAsh that's exactly what I expect to happen. As you can see in the test that I wrote it checks for both. Auto import by completion and code fixes. I don't know why in provided sample code auto import stops working though! |
@RyanCavanaugh I would need some help to continue working on this issue. If someone on the team would clarify how TypeScript determines auto imports from |
Steps to Reproduce:
yarn add @types/classnames
REPLACE_ME
and begin typingclassNames
Does this issue occur when all extensions are disabled?: Yes
Expected: VS Code suggests an auto import of
classNames
from module'classnames
'.Actual: no suggested auto import.
I believe this is something to do with the fact that
classnames
is defined as a UMD module. If I change the type definitions forclassnames
to remove the UMD definition, the auto import does work correctly:Note that VS Code does correctly provide import suggestions after we've finished typing the identifier, when we move our cursor.
This issue is specifically about auto imports inside the suggestions that appear as you're typing.
The text was updated successfully, but these errors were encountered: