Skip to content

TabsProps.onChange TypeScript type is unsatisfiable/incorrect #17503

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

Closed
2 tasks done
davidmfoley opened this issue Sep 20, 2019 · 5 comments
Closed
2 tasks done

TabsProps.onChange TypeScript type is unsatisfiable/incorrect #17503

davidmfoley opened this issue Sep 20, 2019 · 5 comments
Labels
duplicate This issue or pull request already exists

Comments

@davidmfoley
Copy link

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

The typescript type for TabsProps<{}>.onChange is as follows:
((event: ChangeEvent<{}>, value: any) => void) & ((event: FormEvent<HTMLButtonElement>) => void)

This seems incorrect, since it is an intersection type of two function types with different signatures.

I believe this was introduced in this commit:

225badb#diff-c95eab2a6e6470acd8e136b01b514471R42

Expected Behavior 🤔

I think that the left type in the intersection (((event: ChangeEvent<{}>, value: any) => void)) is correct.

Steps to Reproduce 🕹

  1. Upgrade a TypeScript app that uses Tabs with an onChange handler to @material-ui/types 4.1.1

Your Environment 🌎

@material-ui/types: 4.1.1

@eps1lon
Copy link
Member

eps1lon commented Sep 20, 2019

Could you include code that passes typescript but should be rejected? Or is there code that is rejected that should pass in your opinion?

@eps1lon eps1lon added status: waiting for author Issue with insufficient information typescript labels Sep 20, 2019
@davidmfoley
Copy link
Author

This worked with previous versions:

const MyTabs: React.FC<TabsProps> = props => <Tabs {...props} />
const ShouldWork = () => <MyTabs onChange={(e: unknown, value: any) => {}} />

@eps1lon eps1lon added component: tabs This is the name of the generic UI component, not the React module! and removed status: waiting for author Issue with insufficient information labels Sep 20, 2019
@thinksaydo
Copy link

Same problem here since 4.4.1 and newer. ((event: ChangeEvent<{}>, value: any) => void) & ((event: FormEvent<HTMLButtonElement>) isn't the correct type for this. Should be just (event: ChangeEvent<{}>, value: any) => void

@thinksaydo
Copy link

I found that I'm only getting this error when using TabProps while wrapping the Tabs component.

@oliviertassinari oliviertassinari added duplicate This issue or pull request already exists and removed component: tabs This is the name of the generic UI component, not the React module! typescript labels Dec 1, 2019
@oliviertassinari
Copy link
Member

I believe it's a duplicate of #17454.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants