Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import R (ramda) into typescript .ts file

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) {
        // ...
    }    
}

I get error, Cannot find name 'R'

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;
like image 275
Jim Avatar asked Jan 03 '17 11:01

Jim


1 Answers

You have to import it using the import statement:

import * as R from "ramda";

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

like image 170
Saravana Avatar answered Oct 03 '22 22:10

Saravana