-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Bug]: @carbon/react/icons module does not provide IDE import auto-complete #11317
Comments
@jdharvey-ibm trying a quick change over in: #11318 that matches what other icon libraries with sub-folder imports do just in case it's a quickfix. Otherwise, we may need to just generate types for this folder to help out since what VSCode is doing is downloading the types from |
@joshblack sweet! What can I do to help out with testing? |
@jdharvey-ibm something that would help out a ton when it's merged in would be to:
|
@jdharvey-ibm if you have a sec to test out latest, let me know! Should be available now |
Testing it now! |
If I explicitly reference the index.esm file, I get autocomplete: But if I reference If I switch the package.json file in |
@jdharvey-ibm thanks for trying it out! Super interesting 🤔 I assume you don't run into problems with packages like |
I wonder if we should try having the default |
Looks like in the latest update this is still an issue 😞 it seems unable to resolve any kind of type file for that entrypoint. Similarly, it seems like the default types for the package are incorrect on DefinitelyTyped which is causing some of the oddity for imports. It seems like our only way to address this is to offer an |
Any update? |
Hey @TannerS! 👋 It seems like the big thing for incorrect imports is that there is a local cache of packages which are probably being pulled from for completion. In the case of @jdharvey-ibm above, it seemed like a local cache was being used: Deleting that cache entry seemed to fix the issue of "invalid imports" but I would love to hear from you if this helps in the IntelliJ use-case 👀 |
@TannerS it should require no updates to the package itself, it seems like the behavior comes from the TypeScript cache versus the package |
For me on Mac, when I stepped into the definitions file it was pulling from, it was in the node modules cache in my typescipt 4.7 directory ( As a stopgap, what I might do is pull down the type definitions from over in #11533 into a local folder in my repo and include a This is definitely being actively worked on though! @joshblack and I have had some discussions about it. @joshblack Is this enough of an issue to where we should look into deleting the definitions from DefinitelyTyped? |
@jdharvey-ibm good question, I think most downloads are still coming from pre-v11 and so would be helpful for teams wanting to use TS + pre-v11 icons. TypeScript support is definitely one of the biggest blocker for folks moving to v11, though, so I feel kind of stuck with what to do. Do we know if there is a way for the types on DefinitelyTyped to only correspond to pre-v11 versions? |
You should now see the correct types for v11 icons. |
Confirmed that when I import via The main thing still outstanding for this issue is that I don't get the auto-complete from the standard |
Is that something that #11533 would solve? Ideally, types/JSDocs would be shipped with Because even as I type this comment, |
@metonym unfortunately for my use case I don't believe that would help. The issue I have when working with the icons through the |
@jdharvey-ibm Follow-up thought: why not import icons from |
@metonym that's definitely doable! As a general strategy though, we want the |
Package
@carbon/react
Browser
No response
Package version
1.1.0
React version
not specific to a version of react
Description
When importing icons via the
@carbon/react/icons
re-export, no auto-completions are provided in VS Code:versus
@carbon/icons-react
which looks like:It doesn't look like the IDE auto-completion is smart enough to follow the combination of
Object.keys
andObject.defineProperty
to provide the exhaustive list of icons that are available at runtime/build time.Though I'm not sure exactly how to accomplish it, it seems like a more direct re-export of the icons from the
require
d module would be what is needed to get past this.There's also an info message that pops up in vscode for this import which is not present on the icons-react version:
versus icons-react which has a full-blown
d.ts
file to which it links that provides type info:CodeSandbox example
n/a
Steps to reproduce
@carbon/react
into a React project@carbon/react/icons
Code of Conduct
The text was updated successfully, but these errors were encountered: