facebookexperimental/Recoil

[Typescript] Use selectorFamily with an interface

オープン

#629 opened on 2020/09/30

 (7 件のコメント) (8 件のリアクション) (1 人の担当者)JavaScript (1,151 件のフォーク)batch import
TypeScript / Flowhelp wanted

Repository metrics

Stars
 (19,428 個のスター)
PR merge metrics
 (PR metrics pending)

説明

I 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

コントリビューターガイド