-
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
Add TypeScript types to @carbon/react
components
#12513
Comments
@carbon/react
components
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Convert existing propType definitions to Typescript annotations on the NumberInputSkeleton component. This is part of a broader effort to add Typescript annotations to components, tracked in carbon-design-system#12513. Closes carbon-design-system#12549. Type annotation changes only; no breaking feature changes.
Convert existing propType definitions to Typescript annotations on the NumberInput component. This is part of a broader effort to add Typescript annotations to components, tracked in carbon-design-system#12513. Closes carbon-design-system#12548. Type annotation changes only; no breaking feature changes.
Convert existing propType definitions to Typescript annotations on the TableSelectAll component. This is part of a broader effort to add Typescript annotations to components, tracked in carbon-design-system#12513. Closes carbon-design-system#12530. Type annotation changes only; no breaking feature changes.
This comment was marked as off-topic.
This comment was marked as off-topic.
@lewandom Awesome! Please comment on the individual component issues so interest/assignments are visible there in context |
Convert existing propType definitions to Typescript annotations on the NumberInputSkeleton component. This is part of a broader effort to add Typescript annotations to components, tracked in #12513. Closes #12549. Type annotation changes only; no breaking feature changes. Co-authored-by: Taylor Jones <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Alessandra Davila <[email protected]>
Convert existing propType definitions to Typescript annotations on the NumberInput component. This is part of a broader effort to add Typescript annotations to components, tracked in carbon-design-system#12513. Closes carbon-design-system#12548. Type annotation changes only; no breaking feature changes.
* refactor(TableSelectAll): add typescript annotations Convert existing propType definitions to Typescript annotations on the TableSelectAll component. This is part of a broader effort to add Typescript annotations to components, tracked in #12513. Closes #12530. Type annotation changes only; no breaking feature changes. * fix(typescript): fix InlineCheckbox property types Because InlineCheckbox does not have type definitions, it gets its input property type definitions from React.forwardRef, and so does not allow extra properties. This results in errors like: Property 'ariaLabel' does not exist on type 'IntrinsicAttributes & RefAttributes<any>'. when we adopt TS in files that use InlineCheckbox. Since InlineCheckbox is internal-only, policy is not to add types but to mark as type: any. * fix(typescript): fix DataTable exports tests DataTable has a set of tests which check that all files in the directory (with some specific exceptions) export a default component with the same name as the file. This test got the expected name of the component by stripping ".js" from the filename. This won't work for Typescript files, which have a different extension. Stripped off the extension regardless of what it was instead.
any updates on this MR. Is it possible at least to merge the migrations that have been already done. It would be helpful. |
Just wanted to give an update here for anyone considering upgrading. Updating was relatively painless. I'd definitely recommend anyone trying this to use the migration tools provided. After running these, we updated our SASS (which was a bit of a pain just because we've set it up unconventionally), then we went through the components that have changed (surprisingly few) and either wrapped them to not break our own behaviour, or just updated the interface wherever possible. After finally adding a few missing type definitions in a The missing type definitions should not be a blocker, there are so few left and it's pretty straight forward to just add your own type definitions for whatever is missing. Example: // index.d.ts
type OverflowMenuProps = {...}; // use Storybook for reference
declare module "@carbon/react" {
export * from "@carbon/react";
export const OverflowMenu: (props: OverflowMenuProps) => React.ReactNode;
// ....
} |
Hey @Agile-fox
Good catch, it will be tracked via this issue |
Add proper types for parameter to translateWithId() methods. Each component's translateWithId() method can only take a certain list of keys, not any string. Update the Typescript to notate this. For historical reasons most of the existing translation keys are declared in a convoluted way. For example: export const translationIds = { 'increment.number': 'increment.number', 'decrement.number': 'decrement.number', }; type TranslationKey = keyof typeof translationIds; The simpler way is just: type TranslationKey = 'increment.number' | 'decrement.number’; I didn’t update that in this PR, but it’s something to consider for the future. Note that TableToolbarSearch.tsx and MultiSelect.tsx don’t suffer from this problem. Also note that many components declare translateWithId() directly, whereas others do it by extending InternationalProps. I guess all components with translation should extend InternationalProps, but I didn’t update that in this commit either. Refs carbon-design-system#12513.
Add proper types for parameter to translateWithId() methods. Each component's translateWithId() method can only take a certain list of keys, not any string. Update the Typescript to notate this. For historical reasons most of the existing translation keys are declared in a convoluted way. For example: export const translationIds = { 'increment.number': 'increment.number', 'decrement.number': 'decrement.number', }; type TranslationKey = keyof typeof translationIds; The simpler way is just: type TranslationKey = 'increment.number' | 'decrement.number’; I didn’t update that in this PR, but it’s something to consider for the future. Note that TableToolbarSearch.tsx and MultiSelect.tsx don’t suffer from this problem. Refs carbon-design-system#12513.
* fix: translateWithId() parameter types Add proper types for parameter to translateWithId() methods. Each component's translateWithId() method can only take a certain list of keys, not any string. Update the Typescript to notate this. For historical reasons most of the existing translation keys are declared in a convoluted way. For example: export const translationIds = { 'increment.number': 'increment.number', 'decrement.number': 'decrement.number', }; type TranslationKey = keyof typeof translationIds; The simpler way is just: type TranslationKey = 'increment.number' | 'decrement.number’; I didn’t update that in this PR, but it’s something to consider for the future. Note that TableToolbarSearch.tsx and MultiSelect.tsx don’t suffer from this problem. Refs #12513. * chore: extend InternationalProps instead of declaring translateWithId() Refs #12513. * chore: rename InternationalProps --------- Co-authored-by: Taylor Jones <[email protected]>
The scope that was initially planned here is done! There are some follow-on items yet to be tackled: For any bugs related to existing types, please open a new issue |
This issue is to track the implementation of TypeScript definitions for components exported from
@carbon/react
.The lists below organize all exports from the package that need to have types added into three categories: high, medium, and low priority. There is a project board for this effort as well.
How to contribute
Thanks so much for assisting with this huge effort! 🙏
Every checklist item below needs the following:
Closes #12513
REF #16360
High priority
DataTable
Grid
Inputs
useCombobox
instead of<Downshift>
component #12546Medium priority
Low priority
UIShell
UIShell Header
UIShell SideNav
Menu-based components
Hooks
Feature flagged components
The text was updated successfully, but these errors were encountered: