Recoil
Recoil copied to clipboard
[TypeScript] Type {} does not satisfy the constraint 'SerializableParam'
Not so much of a bug as a work around in case anyone runs into a similar problem. When typing any param
parameter (eg atomFamily) the error:
Type {} does not satisfy the constraint 'SerializableParam'
will appear and can be overcome by unioning the two types together as such:
type paramType = SerializableParam & {
id: number
}
@csantos42 - is this a TypeScript typing issue?
Oh yes sorry should have prefaced with that
@csantos42 - Is this somewhat related to this?
Hope this is useful Related commentary SerializableParam @csantos42
If I want to provide a parameter to selectorFamily
interface MySelectorParam {
a: string
b: string
}
For selectorFamily I get an error in the type signature when:
const theThing = selectorFamily<ReturnType, MySelectorParam>({...
but not when:
const theThing = selectorFamily<ReturnType, { a: string; b: string }>({...
Change from interface to type worked for me
Change from interface to type worked for me
That's one weird solution, but as long as it works. 🥇