facebookexperimental/Recoil

[Typescript] Use selectorFamily with an interface

开放

#629 创建于 2020年9月30日

 (7 条评论) (8 个反应) (1 位负责人)JavaScript (1,151 个派生)batch import
TypeScript / Flowhelp wanted

仓库指标

星标
 (19,428 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

贡献者指南