`useTweaks` type not working
ivanross opened this issue · 4 comments
ivanross commented
Description
useTweaks
return type is always any
.
Example
const tweaks = useTweaks({ first: 10 }) // has type any
gsimone commented
@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?
ivanross commented
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
dbismut commented
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 });