-
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]: Invalid TypeScript definition for multiple components (DataTable, Modal) #14831
Comments
Hey can I work on this? |
Might be worth mentioning that ModalFooter also has the same problem with the "children" prop, the docs state it's supposed to be optional and has examples showing it used that way, but the typescript definition marks children as a required prop for ModalFooter :( |
Hi @rwibm please rename bug into something like "DataTable has bad types". In same time, im not sure if making getSelectionPropsArgs nullable makes sense, but this is how my select all looks like so far:
|
I think this is a larger issue with Carbon's TypeScript support in general (it's relatively new for carbon), there seems to be a few definitions that are invalid for several components. I think the carbon team just needs to give somebody a few days to go through all of the definitions and make sure they match what the docs/implementation says the component can do. But it seems they're relying heavily on community contributions at the moment :( |
Hey there, I know this is frustrating and I wish we had the capacity to tackle issues like this promptly. Unfortunately our team is focused on things right now and, as you mention, we're relying on our excellent network of contributors to add types to the react components. We'd welcome a PR for this one if anyone is able. |
Please Assign this issue to me. I'm new to Open Source. |
With the latest carbon version, I notice that the Looks like an issue in the TypeScript type definition. Is this the right issue to track this problem? |
I saw the warning for end of support for v10 ends in September, so I decided to update now that I have free time. I hope 100% coverage for TS is completed before September 😢 |
Migrated to newest version of Carbon a few weeks ago and just want to chime in and say I disagree with this strongly. I've had to declare types for ~4 components I think? Not a big deal at all. Typescript support at this point is not much worse than the definitely typed types from the previous versions. |
I believe that another thing that is relevant to this issue is It either nags you that you missed a required prop or that you used a deprecated one... |
Package
@carbon/react
Browser
No response
Package version
1.38.0
React version
18.2.0
Description
The typescript definition for the getSelectionProps DataTable does not match the JS implementation, which completely breaks strict builds when using the "select all" feature without manually disabling type-checking using comments or casts, which we shouldn't be encouraging.
In TypeScript the getSelectionProps is defined as:
Which causes type checking to error out when getSelectionPropsArgs is undefined, as is expected when using this in TableSelectAll as the examples do.
Reproduction/example
N/A
Steps to reproduce
Try to use TS in strict mode for the DataTable example code found in the storybook for selectable rows and it won't compile without errors.
But to fix it is super easy! Just need to add the missing optional question mark after getSelectionPropsArgs:
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
2024 Update:
This is a deeper issue with the TypeScript support currently implemented, adding more details here to try and clean up these issues as I accidentally reported multiple related issues.
See update here: #13091 (comment)
According to TypeScript the props returned by the getHeaderProps function on data tables has a different onClick event handler type to the one expected by the header component.
Using the example from the storybook gives the following typescript error:
EDIT:
This also appears to affect other parts of the DataTable components, I am now getting errors for the ToolBarSearch component onChange event handler having the wrong type when passing in the onInputChange prop from the render function directly.
Weirdly, the search bar error does not appear on stackblitz, it knows the signatures are different, but doesn't show any errors. But it also thinks that "'DataTable' cannot be used as a JSX component.", so I'm not sure if my example is working correctly on there, but "tsc" locally gives the above error.
EDIT2:
This also affects the TableExpandRow component too, the props don't match.
Reproduction/example
https://stackblitz.com/edit/react-ts-dxtfrs?file=App.tsx
The text was updated successfully, but these errors were encountered: