Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <4123478+tido64@users.noreply.github.com>
- Loading branch information