RamdaJS Typescript 管道定义与类型

问题描述 投票:0回答:1

我正在尝试使用像 TypeScript 这样的 RamdaJs

const x = R.uniq( R.map( R.assoc( 'x', '' ), 
                R.filter<Service, Service[]>( serviceFilter, allServices ) ) 
) as Service[];

我希望我不需要在最后使用

as Service[]
但使用类型它应该有
Service[]
作为响应。

这一切都在管道函数中。

typescript ramda.js
1个回答
0
投票

最新的 ramda.js

uniq
函数输入如下所示:
export function uniq<T>(list: readonly T[]): T[];

因此您应该能够传递泛型类型

Service
并删除
as Service[]

const x = R.uniq<Service>(R.map(...));

© www.soinside.com 2019 - 2024. All rights reserved.