簡體   English   中英

將R(ramda)導入typescript .ts文件

[英]import R (ramda) into typescript .ts file

我試圖使用Ramda.js如下:

/// <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文件,聲明(省略詳細信息)如下:

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

export = R;

您必須使用import語句導入它:

import * as R from "ramda";

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM