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

Typescript: Have non optional type for state property in its onChange handler #1225

Closed
silviuaavram opened this issue Jan 26, 2021 · 0 comments · Fixed by #1582
Closed

Typescript: Have non optional type for state property in its onChange handler #1225

silviuaavram opened this issue Jan 26, 2021 · 0 comments · Fixed by #1582

Comments

@silviuaavram
Copy link
Collaborator

silviuaavram commented Jan 26, 2021

Relevant code or config

Avoid doing this:

    onSelectedItemChange: ({selectedItem}) => {
      selectedItem && addSelectedItem(selectedItem)
    },

Problem description:

Since it's the handler for onSelectedItemChange the types should guarantee that selectedItem is defined.

Suggested solution:

The types use the same interface as onStateChange where all state properties are optional. Each onChange handler should extend this default interface and add its own property as non optional.

export interface UseSelectStateChange<Item>
  extends Partial<UseSelectState<Item>> {
  type: UseSelectStateChangeTypes
}

// this should be added for all on change handlers.
export interface UseSelectSelectedItemChange<Item>
  extends UseSelectStateChange<Item> {
  selectedItem: Item
}

// and then
export interface UseSelectProps<Item> {
  onSelectedItemChange?: (changes: UseSelectSelectedItemChange<Item>) => void,
 // the rest
}
@silviuaavram silviuaavram mentioned this issue Dec 19, 2022
Closed
10 tasks
@silviuaavram silviuaavram mentioned this issue Jul 15, 2023
Closed
7 tasks
mergify bot pushed a commit to SvenKirschbaum/musikbot-frontend that referenced this issue Mar 22, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [downshift](https://downshift-js.com) ([source](https://togithub.com/downshift-js/downshift)) | [`^8.3.1` -> `^9.0.0`](https://renovatebot.com/diffs/npm/downshift/8.5.0/9.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/downshift/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/downshift/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/downshift/8.5.0/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/downshift/8.5.0/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>downshift-js/downshift (downshift)</summary>

### [`v9.0.0`](https://togithub.com/downshift-js/downshift/releases/tag/v9.0.0)

[Compare Source](https://togithub.com/downshift-js/downshift/compare/v8.5.0...v9.0.0)

##### Features

-   V9 ([#&#8203;1582](https://togithub.com/downshift-js/downshift/issues/1582)) ([5b0d503](https://togithub.com/downshift-js/downshift/commit/5b0d5031c1c11455ba18fa1516a259b4ed9357a1))

##### BREAKING CHANGES

-   Release Downshift v9.



**Why**:
Release the changes in:

-   [downshift-js/downshift#1580
-   [downshift-js/downshift#1579
-   [downshift-js/downshift#1583

Closes [downshift-js/downshift#1322.
Closes [downshift-js/downshift#1244.
Closes [downshift-js/downshift#1227
Closes [downshift-js/downshift#1225.



**How**:
Merged the PRs in this branch.



**Checklist**:





-   \[x] Documentation
-   \[x] Tests
-   \[x] TypeScript Types
-   \[ ] Flow Types
-   \[x] Ready to be merged 



</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/SvenKirschbaum/musikbot-frontend).
guilhermespopolin pushed a commit to HedvigInsurance/racoon that referenced this issue Mar 27, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [downshift](https://downshift-js.com) ([source](https://togithub.com/downshift-js/downshift)) | [`8.5.0` -> `9.0.0`](https://renovatebot.com/diffs/npm/downshift/8.5.0/9.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/downshift/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/downshift/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/downshift/8.5.0/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/downshift/8.5.0/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>downshift-js/downshift (downshift)</summary>

### [`v9.0.0`](https://togithub.com/downshift-js/downshift/releases/tag/v9.0.0)

[Compare Source](https://togithub.com/downshift-js/downshift/compare/v8.5.0...v9.0.0)

##### Features

-   V9 ([#&#8203;1582](https://togithub.com/downshift-js/downshift/issues/1582)) ([5b0d503](https://togithub.com/downshift-js/downshift/commit/5b0d5031c1c11455ba18fa1516a259b4ed9357a1))

##### BREAKING CHANGES

-   Release Downshift v9.

<!-- Why are these changes necessary? -->

**Why**:
Release the changes in:

-   [downshift-js/downshift#1580
-   [downshift-js/downshift#1579
-   [downshift-js/downshift#1583

Closes [downshift-js/downshift#1322.
Closes [downshift-js/downshift#1244.
Closes [downshift-js/downshift#1227
Closes [downshift-js/downshift#1225.

<!-- How were these changes implemented? -->

**How**:
Merged the PRs in this branch.

<!-- Have you done all of these things?  -->

**Checklist**:

<!-- add "N/A" to the end of each line that's irrelevant to your changes -->

<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->

-   \[x] Documentation
-   \[x] Tests
-   \[x] TypeScript Types
-   \[ ] Flow Types
-   \[x] Ready to be merged <!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->

<!-- feel free to add additional comments -->

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 2pm every weekday" in timezone Europe/Stockholm, Automerge - "after 6am and before 2pm every weekday" in timezone Europe/Stockholm.

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/HedvigInsurance/racoon).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
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 a pull request may close this issue.

1 participant