Using flow.js in Angular 2 Typescript

寵の児 提交于 2019-11-30 17:56:34

问题


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.

回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/40379116/using-flow-js-in-angular-2-typescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!