typings 安装每个定义两次

typings installs every definition twice

当我使用类型安装定义文件时,会创建两个定义文件:一个在 typings/browser 中,另一个在 typings/main 中。 为什么会发生这种情况以及如何防止它,因为它会导致许多 Dublciate 标识符异常。

您必须将 browser 目录和定义文件或 main 目录和定义文件添加到 tscofing.json 文件的排除部分以消除错误。像这样:

exclude: ["typings/browser", "typings/browser.d.ts"]

exclude: ["typings/main", "typings/main.d.ts"]

简而言之,这样开发人员就可以为浏览器和非浏览器 TypeScript 应用程序公开不同的功能集。