typescript - typings 安装模块依赖

标签 typescript tsd

我正在尝试将 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/

相关文章:

javascript - Angular 2 组件变量范围和引用

javascript - 使用 Bower 发布 TypeScript 库

javascript - 使用 webpack 生成带打字文件的 typescript 库

javascript - 在搜索类型定义时何时使用环境?

typescript - 如何在 Angular 2 中包含 typescript 自定义类型定义?

angular - 在 Angular 2 中获取 "Property X is missing in type error"

reactjs - 使用 typescript 在 create-react-app 中加载 sass

typescript - 为什么不推荐使用 TSD?

javascript - TypeScript如何在数组的Reduce函数中设置累积值和初始值的类型