我正在尝试将 tsd 迁移到 typings,因为 typings 似乎是 tsd 的替代品。所以我为
运行以下命令键入安装 dt~express --global --save
输出是这样的
typings INFO reference 在从“express”(主要)安装期间删除了引用“https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/serve-static/serve-static.d.ts” typings INFO reference 在从“express”(主要)安装期间删除了引用“https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/express-serve-static-core/express-serve-static-core.d.ts” 表示 └──(无依赖)
然后我运行 tsc 来编译我的 express 项目,我得到了这样的错误
typings/globals/express/index.d.ts(4,34):错误 TS2307:找不到模块“serve-static”。 typings/globals/express/index.d.ts(5,27):错误 TS2307:找不到模块“express-serve-static-core”。
似乎 typings 没有为 express 的依赖项安装 typings。我对 tsd 没有这个问题。因为它支持一个选项“--resolve”,它也安装依赖项的所有类型。
打字也有这个“解析”功能吗?
谢谢
最佳答案
不幸的是,似乎没有。 Take a look at the FAQ
References
During installation, all references (E.g. /// ) are stripped. They are stripped because of their ambiguous nature - it can not be determined if the reference should be included within the source or is a dependency. 90% of the time, it's better to strip. If the reference is something you require for the project to work, you can always install the references as dependencies manually.
您必须自己安装任何需要的引用。
this issue中有讨论关于正确的 --follow-references
标签。作者已宣布他正在接受针对该更改的 PR,但据我所知,目前还没有人成功。
关于typescript - typings 安装模块依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37328826/