4

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

from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/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.
Phuc Nguyen
  • 168
  • 3
  • 9

2 Answers2

2

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: https://stackoverflow.com/a/39132461/5789456

Community
  • 1
  • 1
  • Thank you! I'm a newcomer of Angular 2 and i'll read more about new Typescript's definations. – Phuc Nguyen Nov 02 '16 at 16:22
  • My pleasure! I work with Angular since alpha 27 , more than a year ago, and it's the third approach Microsoft applies to definition files. The first was tsd, the second was typings and the last is "@types". The two first use "///ref" operator to recognize definition files, but in "@types" it appears to be different. As I said, i'm not used with "@types". – Reginaldo Camargo Ribeiro Nov 02 '16 at 17:02
  • Could we use FlowJS in Angular 11 or higher version? And will it add any value as most of the lining and other things are pre-handled by TS. – Nah Dec 17 '22 at 12:58
2

import * as Flow from "@flowjs/flow.js"