use-gesture: Typescript: this expression is not callable. Type 'void' has no call signatures
Describe the bug
This expression is not callable.
Type ‘void’ has no call signatures
Sandbox or Video The official demo has this bug too: https://codesandbox.io/s/github/pmndrs/use-gesture/tree/v10/demo/src/sandboxes/draggable-list?file=/src/App.tsx
Information:
- React Use Gesture version: 10
- Typescript ^4.3.2 Checklist:
- I’ve read the documentation.
- If this is an issue with drag, I’ve tried setting
touch-action: none
to the draggable element.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 18
@CKGrafico this issue is closed because I can’t identify it, so I’m not even working on it. You’re welcome to submit a sandbox highlighting a problem.
the other option is to do const bind:any = useDrag(); that way you dont have to mess with tsconfig.
Setting
strictNullChecks: true
in my tsconfig.json fixed it for me.For anyone looking for a workaround that retains type safety and doesn’t change any config:
then…
This is the same type as declared in the use-gesture types - but be careful when updating. I’m on @use-gesture/react@10.2.22.
Code snippet take from the README
Thanks for reporting this, but it’s not a bug in the lib 😃
Here’s the linting in a properly configured project:
I’ve just add
tsconfig.json
files to all typescript sandboxes and now it works fine: the official example link is actually: https://codesandbox.io/s/github/pmndrs/use-gesture/tree/main/demo/src/sandboxes/draggable-list?file=/src/App.tsxYou probably copied an outdated link from the beta v10 documentation, that I just corrected (so thanks!).