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

[Bug]: Some components are missing "index" files (both .js and .d.ts), which breaks auto-complete #14569

Closed
2 tasks done
rwibm opened this issue Sep 1, 2023 · 4 comments
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 🐛

Comments

@rwibm
Copy link

rwibm commented Sep 1, 2023

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.

image

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

  1. Create a blank project using Carbon within WebStorm
  2. Try to use any component within UIShell or StructuredList
  3. WebStorm and WebPack will not recognise the import paths due to missing indexes

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

@rwibm
Copy link
Author

rwibm commented Oct 13, 2023

Just noting here for reference: this issue also seems to affect both Modal and MultiSelect components too.

With modal you can import everything except the actual Modal component (composed and all sub-modal components work, but the "Modal" component itself isn't exported according to typescript).

With multiselect neither the normal MultiSelect or the FilterableMultiSelect are working:

image

EDIT 2: TreeView and TreeNode also have the same issue.
EDIT 3: CodeSnippet and ErrorBoundary are other examples of this.

@tay1orjones
Copy link
Member

@rwibm Thanks for reporting. This looks to me like the IDE is flagging the items that don't have a TypeScript definition file yet. I think this might be a duplicate of #13091?

@rwibm
Copy link
Author

rwibm commented Nov 22, 2023

Ah yes, apologies, I must have missed that one. Feel free to close this issue if it's not needed.

@tay1orjones
Copy link
Member

Duplicate of #13091

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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 🐛
Projects
Status: Done
Development

No branches or pull requests

3 participants