将R(ramda)导入typescript .ts文件 [英] import R (ramda) into typescript .ts file

查看:732
本文介绍了将R(ramda)导入typescript .ts文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am attempting to use Ramda.js as follows:

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




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

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

In the case of the ramda/index.d.ts file, the declaration (with detail omitted) is as follows:

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

export = R;


推荐答案

你必须使用<$ c $导入它c> import 声明:

import * as R from "ramda";

此外,您不必使用 ///< reference /> ,只需执行 npm install --save @ types / ramda

Also, you don't have to use /// <reference /> anymore, just do npm install --save @types/ramda.

这篇关于将R(ramda)导入typescript .ts文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆