所以我在过去几天一直在尝试使用TypeScript,我在安装外部模块的定义时遇到了问题.
如果我像这样使用tsd,我没有问题:
tsd install express
然而,似乎tsd已被弃用,我应该使用打字.
所以我尝试运行这个命令:
typings install --ambient express
这是输出:
typings INFO reference Stripped reference "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/serve-static/serve-static.d.ts" during installation from "express"
typings INFO reference Stripped reference "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/express-serve-static-core/express-serve-static-core.d.ts" during installation from "express"
express
└── (No dependencies)
然后我必须手动安装剥离的引用,当我这样做时,我仍然会在使用tsc编译时出错,但是当我使用tsd时,所有引用都已安装,并且在编译期间我没有遇到任何错误.
我只想尽可能简单地安装定义.
使用tsd是否安全,或者将来可能会遇到一些问题?
为什么没有打字安装它们?
想象一下,如果你运行npm install express然后你得到一个依赖项列表,你必须递归安装所有依赖项.
我应该花多少时间来安装定义文件?
我在网上找不到答案.别人怎么处理这个?
如果某些模块没有可用的定义,我该怎么办?
最佳答案 正如@BrunoLM在评论中指出的那样,随着TypeScript 2.0的发布,这就是现在安装声明文件的方法:
npm i @types/express
参考文献:
> TypeScript 2.0 is now available!
> Consumption – TypeScript