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
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 😄

extends React.HTMLProps<HTMLButtonElement> {}

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.

suppressRefError?: boolean;
}

export interface GetItemPropsOptions<Item>
extends OptionalExtraGetItemPropsOptions {
extends Record<string, any> {
index?: number
item: Item
}

export interface PropGetters<Item> {
getRootProps: (options: GetRootPropsOptions) => any
getToggleButtonProps: (options?: getToggleButtonPropsOptions) => any
getToggleButtonProps: (options?: GetToggleButtonPropsOptions) => any
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.

getInputProps: (options?: GetInputPropsOptions) => any
getItemProps: (options: GetItemPropsOptions<Item>) => any
}
Expand Down