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

fix: convert menubutton to typescript, and do other menu typescript cleanup. #15447

Merged
merged 1 commit into from
Feb 16, 2024
Merged

fix: convert menubutton to typescript, and do other menu typescript cleanup. #15447

merged 1 commit into from
Feb 16, 2024

Conversation

wkeese
Copy link
Contributor

@wkeese wkeese commented Dec 26, 2023

This builds on #15361 to do a few more menu-related Typescript updates:

  • MenuButton: Convert to Typescript.
  • MenuContext: Specify type for context. There’s contradictory evidence though about whether payload is mandatory or optional.
  • Menu: Minor cleanup including specifying that when x and y are arrays, the arrays contain exactly two numbers.
  • MenuItem: Convert some “any” types into actual types, including converting MenuItemRadioGroup to a generic. Also the same cleanup as above about x and y as arrays. Ignore spacing diffs.
  • useAttachedMenu() - Convert to Typescript.

I had to add @ts-ignore to some of the PropTypes declarations for reasons I don't understand. I'm not too worried about it since PropTypes declarations are essentially deprecated.

Also, I know the doc said not to convert internal files to Typescript but it didn’t seem feasible to do this conversion without useAttachedMenu.js and MenuContext.ts having the right types, and it didn’t seem feasible for them to have the right types without converting them to Typescript.

@wkeese wkeese requested a review from a team as a code owner December 26, 2023 13:06
@wkeese wkeese requested review from tw15egan and guidari December 26, 2023 13:06
Copy link

netlify bot commented Dec 26, 2023

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1623130
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/658acfde58e6f10008b4a7df
😎 Deploy Preview https://deploy-preview-15447--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 26, 2023

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 8549174
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/65ce6157f09232000880d0b4
😎 Deploy Preview https://deploy-preview-15447--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@andreancardona
Copy link
Contributor

@wkeese Hey Bill, is there a way you can take a look at these merge conflicts? Thank you!

@wkeese
Copy link
Contributor Author

wkeese commented Jan 24, 2024

Looks like the conversion was already mainly handled by #15361 (cc @mattborghi). The main thing left in my PR is MenuButton, but I also tightened up a few Typescript declarations. I rebased my PR and also updated the description above.

@wkeese wkeese changed the title fix: convert menu, menubutton, and menuitem to typescript fix: convert menubutton to typescript, and do other menu typescript cleanup. Jan 24, 2024
This builds on #15361 to do a few more menu-related Typescript updates:

* MenuButton: Convert to Typescript.
* MenuContext: Specify type for context. There’s contradictory evidence though about whether payload
  is mandatory or optional.
* Menu: Minor cleanup including specifying that when x and y are arrays, the arrays contain exactly
  two numbers.
* MenuItem: Convert some “any” types into actual types, including converting MenuItemRadioGroup to
  a generic.  Also the same cleanup as above about x and y as arrays. Ignore spacing diffs.
* useAttachedMenu() - Convert to Typescript.

I had to add @ts-ignore to some of the PropTypes declarations for reasons I don't understand.
I'm not too worried about it since PropTypes declarations are essentially deprecated.

Also, I know the doc said not to convert internal files to Typescript but it didn’t seem feasible
to do this conversion without useAttachedMenu.js and MenuContext.ts having the right types,
and it didn’t seem feasible for them to have the right types without converting them to Typescript.

Menu, MenuButton and MenuItem were left out of the list on #12513 but I assume
they should be updated too.  Actually, I need MenuButton and MenuItem to be
updated before I can upgrade to Carbon 11.

Other notes:

I had to add @ts-ignore to the PropTypes declarations for reasons I don't
understand.  I'm not too worried about it since PropTypes declarations are
essentially deprecated.

Also, I know the doc said not to convert internal files to Typescript but it didn’t
seem feasible to do this conversion without useAttachedMenu.js and
MenuContext.ts having the right types, and it didn’t seem feasible for them
to have the right types without converting them to Typescript.
@wkeese
Copy link
Contributor Author

wkeese commented Feb 16, 2024

@tay1orjones, @andreancardona - I fixed the merge conflicts. This is the second time it's happened, so hopefully this PR can be merged soon. The MenuButton conversion to Typescript changed the indentation, so git diff and git merge are useless. It doesn't even realize that index.tsx is just index.js renamed. Even though I used git mv, as that command is irrelevant to how git detects file renames.

Copy link
Collaborator

@tw15egan tw15egan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really appreciate all your work on this @wkeese! LGTM 👍🏻 ✅

Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀
Thanks for the contribution!

@guidari guidari added this pull request to the merge queue Feb 16, 2024
Merged via the queue into carbon-design-system:main with commit 00dc60f Feb 16, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants