You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(types): remove 'this' binding expectations on hook fn types (#736)
* feat(types): set void as this type of hook fns
This change improves the experience for TypeScript users that have the
[`unbound-method`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/unbound-method.md)
rule enabled. Without this change, check failures occur when users
attempt to use destructured references to the functions returned in the
`useAsyncStorage` hook's envelope object.
Example:
```typescript
const { getItem, setItem } = useAsyncStorage('someKey')
// eslint@typescript-eslint/unbound-method
//
// Avoid referencing unbound methods which may cause unintentional
// scoping of `this`. If your function does not access `this`, you can
// annotate it with `this: void`, or consider using an arrow function
// instead.
```
* chore: define hook types with arrow fns
This approach achieves the same end result as explicitly declaring the `this` type to be void and is more familiar to readers who know JS.
Co-authored-by: Tommy Nguyen <[email protected]>
0 commit comments