将R(ramda)导入typescript .ts文件

Jim*_*Jim 4 javascript typescript ramda.js

我试图使用Ramda.js如下:

/// <reference path="../../../node_modules/@types/ramda/index.d.ts" />
module App {
    var settab = R.once((element) => current(element));  
    function current(li: any) {
        // ...
    }    
}
Run Code Online (Sandbox Code Playgroud)

我收到错误,找不到名字'R'

对于ramda/index.d.ts文件,声明(省略详细信息)如下:

declare var R: R.Static;    
declare namespace R {
    type Ord = number | string | boolean;
    interface Static {
        // .........
    }
}

export = R;
Run Code Online (Sandbox Code Playgroud)

Sar*_*ana 7

您必须使用以下import语句导入它:

import * as R from "ramda";
Run Code Online (Sandbox Code Playgroud)

此外,您不必再使用/// <reference />了,只需这样做npm install --save @types/ramda.