[Bug]: Some components are missing "index" files (both .js and .d.ts), which breaks auto-complete #14569
Closed
2 tasks done
Labels
area: typescript
needs: community contribution
Due to roadmap and resource availability, we are looking for outside contributions on this issue.
role: dev 🤖
severity: 3
https://ibm.biz/carbon-severity
status: help wanted 👐
type: bug 🐛
Package
@carbon/react
Browser
No response
Package version
1.36.0
React version
18.2.0
Description
When using some components in the react package they are missing index files, which WebStorm uses for parsing imports.
This causes auto-complete to break and shows loads of linting errors on pages where these components are used.
I've looked into this and it seems to be due to the components I'm using (anything in UIShell and StructuredList) not including index files within the components. This works fine when I go to compile with vite (WebPack/WebStorm doesn't like it unless I import from @carbon/react/es/components/UIShell, but this full import path doesn't work in vite), but the IDE never detects these imports unless I manually add an index file to the correct place within node_modules, which fixes it (WebPack, WebStorm, and Vite are all happy importing from "@carbon/react" with the index files added to UIShell and StructuredList).
Most other components have these indexes, and work fine just like these do after adding the missing indexes, but obviously manually creating an index every time I update carbon is not a reasonable workaround.
Left: node_modules/@carbon/react/js/components/UIShell/index.d.ts [new file], right: project file using the imported components.
The screenshot above shows the working import for Toggle, and broken imports for everything inside UIShell other than the few items I manually added to an index file as a test fix.
I've tried so many different config options and things that make webstorm work break vite, and vice versa, so it would be really nice if the carbon team can add these missing indexes to the official repo pretty please.
P.S. this isn't a typescript issue, when I was using JS in carbon v10 it also used to have the exact same problem with these 2 components too!
Reproduction/example
N/A as vite processes these imports correctly, WebStorm and WebPack don't
Steps to reproduce
Suggested Severity
Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.
Application/PAL
IBM Internal
Code of Conduct
The text was updated successfully, but these errors were encountered: