相关疑难解决方法(0)

我必须为TypeScript中的高阶函数类型指定参数名称吗?

试图使用TypeScript弄湿我的脚,但我一直遇到麻烦今天,一个旧功能浮出水面,并且作为练习,我很好奇是否可以将其转换为TypeScript。到目前为止,颈部已经完全疼痛。

declare type Ord = number | string;

// type signature for f sucks really bad
// (f: Ord => Ord => boolean) would be really nice, if possible
// but instead I have to give names (_) for the parameters? dumb
const arrayCompare = (f: (_: Ord) => (_: Ord) => boolean) => ([x,...xs]: Ord[]) => ([y,...ys]: Ord[]): boolean => {
  if (x === undefined && y === undefined)
    return true;
  else if …
Run Code Online (Sandbox Code Playgroud)

higher-order-functions typescript

8
推荐指数
1
解决办法
1233
查看次数

标签 统计

higher-order-functions ×1

typescript ×1