facebookexperimental/Recoil

[Typescript] Use selectorFamily with an interface

Open

#629 建立於 2020年9月30日

在 GitHub 查看
 (7 留言) (8 反應) (1 負責人)JavaScript (19,428 star) (1,151 fork)batch import
TypeScript / Flowhelp wanted

描述

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

貢獻者指南