6

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;
Jim
  • 14,952
  • 15
  • 80
  • 167

1 Answers1

12

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.

Saravana
  • 37,852
  • 18
  • 100
  • 108
  • I get the error 'cannot use imports, exports, or module augmentations when '--module' is 'none'. Which module option will get me closest to what I used to have with `/// `? – Jim Jan 03 '17 at 11:10
  • You can set `compilerOptions.module` as `commonjs` in your `tsconfig.json` and use `import`statements. – Saravana Jan 03 '17 at 11:30