Phuc Nguyen Phuc Nguyen - 1 month ago 26
TypeScript Question

Using flow.js in Angular 2 Typescript

I want to integrate flowjs or ng-flow to my Angular 2 application.

I've installed the flowjs typings using

npm install --save-dev @types/flowjs


But when I import it in my component
import { Flow } from 'flowjs';
the console thrown an error

/node_modules/@types/flowjs/index.d.ts' is not a module.


I got this error before when creating my own modules and it was caused when there is nothing exported class or module inside the file index.d.ts. I looked at the repository and my guess is: the error is caused because there's nothing exported inside the file. But as same as other definition files you don't need to import the definitions, it is global definitions, so you just need to add it in your compiler life cycle using the "///ref" operator. I'm not used with this new Typescript definition files approach (@types), but there's a post explaining very well how to add it to your compiler life cycle: