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 callback types #5067

Merged
merged 3 commits into from Oct 19, 2023
Merged

Fix callback types #5067

merged 3 commits into from Oct 19, 2023

Conversation

nmay231
Copy link
Contributor

@nmay231 nmay231 commented Oct 18, 2023

As discussed in Discord, this changes all callback types from methods to function attributes ({ callback(a: A): T } => { callback: (a: A) => T }). This prevents type variance bugs, such as the following where the real type of onChange is (value: string | null) => void.

export default function App() {
  function expectsAString(value: string) {
    // null error is only caught at runtime, currently
    console.log(value.length); // TypeError: Cannot read properties of null (reading 'length')
  }

  return (
      <Select
        onChange={expectsAString}
        data={["React", "Vue", "Angular"]}
        clearable
      />
  );
}

Also synchronized .nvmrc and .tool-versions.

@rtivital rtivital merged commit 5b861a7 into mantinedev:master Oct 19, 2023
1 check passed
@rtivital
Copy link
Member

Thanks!

@nmay231 nmay231 deleted the fix-callback-types branch October 19, 2023 05:00
@nmay231
Copy link
Contributor Author

nmay231 commented Oct 19, 2023

And thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants