Typescript 2.1,browserify,Angular 2缺少类型

时间:2016-12-06 05:19:01

标签: javascript angular typescript

`
vscode 1.7
Typescript 2.1.1
Angular 2 latest
package.json 
"dependencies": {
    "@angular/common": "^2.2.4",
    "@angular/compiler": "^2.2.4",
    "@angular/core": "^2.2.4",
    "@angular/platform-browser": "^2.2.4",
    "@angular/platform-browser-dynamic": "^2.2.4",
    "@angular/router": "^3.2.4",
    "@types/angular2": "0.0.2",
    "@types/systemjs": "^0.19.32",
    "angular2": "^2.0.0-beta.17",
    "browserify": "^13.1.1",
    "es6-shim": "^0.35.1",
    "plugin-typescript": "^5.3.1",
    "reflect-metadata": "^0.1.2",
    "rxjs": "^5.0.0-beta.6",
    "systemjs": "^0.19.41",
    "tsify": "^2.0.3",
    "typescript": "^2.1.1",
    "zone.js": "^0.6.12"
  }

 tsconfig.json
{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "removeComments": true,
    "preserveConstEnums": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "target": "es6",
    "allowJs": true
  },
  "exclude": [
    "node_modules",
    "**/*.spec.ts"
  ]
}

`

我正在运行脚本 tsc index.ts > ts.js && browserify ts.js > bundle.js

并且打字稿编译器有各种各样的抱怨:

node_modules/@angular/compiler/src/compile_metadata.d.ts(369,30): error TS2304: Cannot find name 'Promise'.

node_modules/@angular/compiler/src/directive_normalizer.d.ts(38,72): error TS2304: Cannot find name 'Promise'.

和其他各种。

1 个答案:

答案 0 :(得分:0)

通过添加解决 import "./node_modules/@types/es6-shim"到我的index.ts