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: a more accurate type for the Select onChange prop #1502

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

haideralsh
Copy link
Contributor

@haideralsh haideralsh commented Jan 7, 2025

Description

Consider this example:

export const options = [{ value: "accepted", label: "Accepted" }];

function WithMulti() {
  return (
    <Select
      options={options}
      multiselect
      // value here is of type NDSOptionValue[]
      onChange={(value) => {
        // Do something with the value
      }}
    />
  );
}

function WithSingle() {
  return (
    <Select
      options={options}
      // value here is of type NDSOptionValue
      onChange={(value) => {
        // Do something with the value
      }}
    />
  );
}

TypeScript will infer the right type depending on whether multiselect is true or false.

Changes include

  • breaking change: a change that is not backwards-compatible and/or changes current functionality
  • fix: a non-breaking change that solves an issue
  • feature: a non-breaking change that adds functionality
  • chore: contains no changes affecting the library, such as documentation or test updates

Feature checklist

  • Appropriate tests have been added
  • Documentation has been updated
  • Accessibility has been considered

@haideralsh haideralsh merged commit e417d24 into master Jan 7, 2025
4 checks passed
@haideralsh haideralsh deleted the fix-select-on-change-type branch January 7, 2025 21:40
Copy link

github-actions bot commented Jan 7, 2025

🎉 This PR is included in version 13.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

1 participant