[Typescript] Use selectorFamily with an interface
See original GitHub issueI have a simple interface called Filters
export interface Filters {
search: string;
}
And I’m trying to use it like with selectorFamily
like that: selectorFamily<Patient[], Filters>
I’m getting typescript error
Type ‘Filters’ does not satisfy the constraint ‘SerializableParam’. Type ‘Filters’ is not assignable to type ‘Readonly<{ [key: string]: SerializableParam; }>’. Index signature is missing in type ‘Filters’.ts(2344)
If I simply extract the interface
selectorFamily<Patient[], { search: string }>
it works, but I would happy to not do it
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:6 (1 by maintainers)
Top Results From Across the Web
selectorFamily(options) - Recoil
A selectorFamily is a powerful pattern that is similar to a selector , but allows you to pass parameters to the get and...
Read more >TypeScript recoil cheat sheet - SaltyCrane
This is a list of TypeScript types for recoil generated from the declaration files ... P extends SerializableParam> (interface); AtomOptions<T> (interface) ...
Read more >Recoil with React and TypeScript - DEV Community
Recoil is yet another state management library for React, I just wanted to give it a try so I decided to re-create my...
Read more >Integrate Recoil with TypeScript to share your state across ...
In Recoil, we can then use the selector or a selectorFamily . A selectorFamily is a pattern similar to a selector , but...
Read more >Type interface for selectors constant - Stack Overflow
header__toggle-mode'), rotateBtnStr: '.content__topic-item-btn', },. }; typescript · types · interface.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Does this relate to #457, too?
I expanded upon what @Kjaer wrote and have this type in my project:
I’m wondering if we should move a fix upstream somehow.
A demonstration of the ‘bug’ can be found here. But I’ve not been able to find a library-level fix for this when Googling…
I am dealing with this issue with using Mapped Types(https://www.typescriptlang.org/docs/handbook/2/mapped-types.html)
let’s say I’ve got this
interface
And I’ve got a
selectorFamily
as follows:Typescript will throw this error:
and I added this generic type mapper:
Typescript will happy now. Hope this will help you all…