Closed ivanross closed 3 years ago
@ivanross useTweaks should be used as a generic, the signature is
export function useTweaks<T extends Schema>(schema: T, settings?: Settings): UseTweaksValues<T>
So
const tweaks = useTweaks<{ first: number }>({ first: 10 });
I do agree that it doesn't seem to be working, though
@dbismut I remember this was working in the examples, could it be a problem with the npm bundle?
Hi @gsimone thank you for the quick answer!
I see that useTweaks
is generic, and if you check the codesandbox it seems that Typescript understands it
Hi guys, I don't know what's happening... This is what I get in the example from the repo, maybe there's something wrong when bundling types as you're saying GM... We're using TypeScript 4, not sure if this has an impact but even upgrading @ivanross sandbox didn't seem to solve it...
But in any case:
// you shouldn't be using the shouldn't need to do this
const tweaks = useTweaks<{ first: number }>({ first: 10 });
// this should work instead
const tweaks = useTweaks({ first: 10 });
@gsimone @dbismut Just opened a PR to solve this!
Description
useTweaks
return type is alwaysany
.Example
https://codesandbox.io/s/usetweaks-type-issue-1k2lo