正在将打字从 0.x 升级到 1.x。 /打字在哪里?

Upgrading typings from 0.x to 1.x. Where is /typings?

在 TypeScript 中编写一个 Angular 2 应用程序,我试图遵循 5 Min Quickstart guide. Recently the npm typings package went from 0.x to 1.x. According to the official instructions,我们应该在升级时删除 /typings,所以这就是我所做的。删除该目录后,我 运行 npm uninstall typings,然后 npm install typings。我现在已经安装了 typings 1.1.0

这是我的typings.json

{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160317120654",
    "jasmine": "registry:dt/jasmine#2.2.0+20160505161446",
    "node": "registry:dt/node#4.0.0+20160509154515"
  }
}

问题是,我预计安装会创建一个新的 /typings 并用 new file structure 填充它。然而,我还是没有/typings。尝试 运行 typings install 会抛出错误 'typings' is not a recognized command, program or batch file(我在 Windows 7)。给出了什么?

为什么会出现问题:typescript 编译器会抛出很多 "Cannot find name 'Promise'" (or 'Set' or 'Map') 错误,除非我引用(现已删除)///<reference path="../typings/main/ambient/es6-shim/es6-shim.d.ts"/>

我前段时间也遇到过这个问题。为了修复它,我添加了 ///<reference path="../../node_modules/angular2-in-memory-web-api/typings/browser.d.ts" /> tsd.d.ts 文件的引用路径。路径可能会有所不同,具体取决于您的环境设置方式。但是如果我没记错的话 browser.d.ts 有那些打字的参考资料。

这是一个相关的问题预发布候选。

typings install 不会被识别(可能是因为我没有全局安装它)。要创建和填充 /typings,我需要执行 npm run typings install。这创建了 /typings/globals 并用我的 typings.json.

中的包填充了它

为了处理 "Cannot find name 'Promise'" 错误,我将 bootstrap 文件中的参考路径更改为

旧:///<reference path="../typings/main/ambient/es6-shim/es6-shim.d.ts"/>

到新:///<reference path="../typings/globals/core-js/index.d.ts"/>

鉴于 Angular 2 最近在 typings.json 中将 es6-shim 替换为 core-js