I am getting to grips with Typescript. I am having issues with using fs.
The following code produces this error:
Ingest.ts(4,21): error TS2307: Cannot find module 'fs'
// <reference path="typings/node/node.d.ts"/>
import * as fs from "fs";
var data = fs.readFileSync('matt.txt');
typings/node/node.d.ts(512,16): error TS2304: Cannot find name 'IterableIterator'.
typings/node/node.d.ts(514,13): error TS2304: Cannot find name 'IterableIterator'.
typings/node/node.d.ts(515,15): error TS2304: Cannot find name 'IterableIterator'.
npm install -g typescript
npm install -g tsd@next
cd <project folder>
tsd install node
OK, a few things here.
TSD is done, use
npm install -g typings. With
typings, you need to know the repository for the type files, it will be one of the columns returned when you do a
typings search <package>. I've had most of my type files come from the DefinitelyTyped repo. To install a package from there, you do
typings install dt~<package>.
Second, you error with the
IterableIterator, I've already reported this to the Node type team, they are working on a resolution for it, but you can get around it in the mean time by installing the core-js types
typings install dt~core-js --global