我正在尝试安装fabric的类型定义(https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/fabric/),但我无法找到正确的键入命令。
一开始,我尝试了typings install dt~fabric --global --save,得到了以下错误:$typings install dt~fabric --global --save typings ERR! message Attempted to compile "fabric" as a global module, but it looks like an external module. You'll need to remove the global option to continue.
然后我尝试了typings install dt~fabric --save,输入命令成功了,但是typings/modules/fabric/index.d.ts文件与原始文件https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/fabric/index.d.ts不同。typings命令用declare module 'fabric' {}包装原始内容,这将导致在.d.ts文件中的语句export as namespace fabric;处出现编译器错误Error:(9, 1) TS1316:Global module exports may only appear at top level.。
输入版本2.1.0
发布于 2017-08-07 00:17:01
npm install --save-dev @types/fabric会成功的,根据国家预防机制的文件。
你可以看到在这里输入定义。
我在学习Fabric时使用了这种方法,这是在理解API方面的一个巨大的帮助,因为是IntelliSense。
此外,如果您在任何//@ts-check文件的顶部使用*.js,它还会给出它认为正确的IntelliSense的粗略估计。
TypeScript 2.3及更高版本支持.js文件中带有--校验.js的类型检查和报告错误模式。医生们解释了它的工作原理。
https://stackoverflow.com/questions/42547692
复制相似问题