关于javascript:将R(ramda)导入typescript .ts文件

import R (ramda) into typescript .ts file

我正在尝试如下使用Ramda.js:

1
2
3
4
5
6
7
/// <reference path="../../../node_modules/@types/ramda/index.d.ts" />
module App {
    var settab = R.once((element) => current(element));  
    function current(li: any) {
        // ...
    }    
}

I get error, Cannot find name 'R'

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

1
2
3
4
5
6
7
8
9
declare var R: R.Static;    
declare namespace R {
    type Ord = number | string | boolean;
    interface Static {
        // .........
    }
}

export = R;

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

1
import * as R from"ramda";

另外,您不必再使用/// ,只需执行npm install --save @types/ramda