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

Refactor: Add Menu/MenuItem types #15361

Merged
merged 3 commits into from
Jan 18, 2024

Conversation

mattborghi
Copy link
Contributor

Closes #15177

Add Typescript types for Menu and MenuItem.

Changelog

New

  • Add Typescript types for Menu and MenuItem.

Changed

  • File extensions changed from .js to .tsx/.ts.

Removed

  • N/A

Testing / Reviewing

  • Storybook runs as before.
  • Unit tests passing.

Copy link

netlify bot commented Dec 10, 2023

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c2f27d9
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/65947899ec65bc00081cfc38
😎 Deploy Preview https://deploy-preview-15361--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.

@mattborghi mattborghi marked this pull request as ready for review December 16, 2023 22:43
@mattborghi mattborghi requested a review from a team as a code owner December 16, 2023 22:43
Copy link
Contributor

@andreancardona andreancardona left a comment

Choose a reason for hiding this comment

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

Other than one small comment - looks good!

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.

LGTM 👍 ✅

@tw15egan tw15egan added this pull request to the merge queue Jan 18, 2024
Merged via the queue into carbon-design-system:main with commit fdce3b6 Jan 18, 2024
20 checks passed
@carbon-automation
Copy link
Contributor

Hey there! v11.48.0 was just released that references this issue/PR.

github-merge-queue bot pushed a commit that referenced this pull request Feb 16, 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.
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.

Add TypeScript types to Menu, MenuItem
3 participants