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

Improved typings for getMenuProps #534

Merged
merged 4 commits into from
Aug 20, 2018
Merged

Improved typings for getMenuProps #534

merged 4 commits into from
Aug 20, 2018

Conversation

franklixuefei
Copy link
Collaborator

@franklixuefei franklixuefei commented Aug 7, 2018

Fixes the typing part of #490

Why: The typings for getMenuProps was too broad.

How:
Created interfaces for the types of parameters of getMenuProps

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

kentcdodds
kentcdodds previously approved these changes Aug 7, 2018
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

LGTM, but I'd like a typescript maintainer to review as well 👍

@franklixuefei
Copy link
Collaborator Author

@kentcdodds Thanks! Who would you recommend for this review?

@codecov
Copy link

codecov bot commented Aug 7, 2018

Codecov Report

Merging #534 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #534   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           3      3           
  Lines         349    349           
  Branches       84     84           
=====================================
  Hits          349    349

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e34f5bc...480b2fd. Read the comment docs.

@kentcdodds
Copy link
Member

Hopefully they're watching the repo and will get to it when they have an opportunity... We'll give them a day or two.

Copy link
Collaborator

@pbomb pbomb left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @franklixuefei. I suggested a few changes.

interface OptionalExtraGetItemPropsOptions {
[key: string]: any
export interface GetMenuPropsOptions<Item>
extends Record<string, any> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't seem to be quite right. I also don't understand what the <Item> generic type is doing here as it doesn't appear to be used.

From looking over the docs, this is what I would expect this type to look like:

export interface GetMenuPropsOptions {
  refKey?: string
  aria-label?: string
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are completely right. I kind of copied the interface from GetMenuItemOptions which has the generic type parameter and I forgot to remove it.

refKey?: string;
}

export interface GetMenuPropsOtherOptions<Item> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's remove the <Item> part of this as it isn't adding any value.

getLabelProps: (options?: GetLabelPropsOptions) => any
getMenuProps: (options?: {}) => any
getMenuProps: (options?: GetMenuPropsOptions<Item>, otherOptions?: GetMenuPropsOtherOptions<Item>) => any
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's remove the <Item> occurrences on this line.

@@ -105,24 +105,29 @@ export interface GetInputPropsOptions
export interface GetLabelPropsOptions
extends React.HTMLProps<HTMLLabelElement> {}

export interface getToggleButtonPropsOptions
export interface GetToggleButtonPropsOptions
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for reviewing this PR! I've made changes as necessary and please take a look 😄

@franklixuefei
Copy link
Collaborator Author

franklixuefei commented Aug 8, 2018

I haven't figured out why it's failing. Could someone help me with this?

@franklixuefei
Copy link
Collaborator Author

Ping 😄

@kentcdodds kentcdodds merged commit 0ff43a3 into master Aug 20, 2018
@kentcdodds kentcdodds deleted the franklixuefei-patch-1 branch August 20, 2018 18:13
@kentcdodds
Copy link
Member

🎉 This PR is included in version 2.1.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Rendez pushed a commit to Rendez/downshift that referenced this pull request Sep 30, 2018
* Improved typings for getMenuProps

Fixes the typing part of downshift-js#490

* Update index.d.ts

* Fixed build error

* Update index.d.ts
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.

3 participants