gulp打字稿:错误TS1005

时间:2016-08-29 07:00:07

标签: angular typescript gulp material-design

我正在创建angular2 typescript应用程序。我使用angular / material2来呈现更好的设计。至于建设项目 - 我正在使用gulp。

问题陈述:我将@angular/router-deprecated更改为@angular/router,并被迫更新其他软件包(@angular/core@angular2-material等)

之后,gulp构建停止工作并显示以下错误:

.../node_modules/@angular2-material/button/button.d.ts(28,14): error TS1005: '=' expected
.../node_modules/@angular2-material/button/button.d.ts(28,22): error TS1005: ';' expected
.../node_modules/@angular2-material/button/button.d.ts(29,14): error TS1005: '=' expected
.../node_modules/@angular2-material/button/button.d.ts(29,28): error TS1005: ';' expected
.../node_modules/@angular2-material/input/input.d.ts(50,14): error TS1005: '=' expected.
.../node_modules/@angular2-material/input/input.d.ts(50,21): error TS1005: ';' expected.
.../node_modules/@angular2-material/input/input.d.ts(51,14): error TS1005: '=' expected.
.../node_modules/@angular2-material/input/input.d.ts(51,19): error TS1005: ';' expected.

我的gulp编译代码如下:

const gulp = require('gulp');
const tsc = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
const tsProject = tsc.createProject('tsconfig.json');

module.exports = function() {
  const tsResult = gulp.src('src/**/*.ts')
    .pipe(sourcemaps.init())
    .pipe(tsc(tsProject));

  return tsResult.js
    .pipe(sourcemaps.write("."))
    .pipe(gulp.dest("dist"));
};

main.ts:

///<reference path="../../typings/index.d.ts"/>
import { bootstrap } from '@angular/platform-browser-dynamic';

import { AppComponent } from './app.component';

import { HTTP_PROVIDERS } from '@angular/http';

bootstrap(AppComponent, [HTTP_PROVIDERS]);

tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "outDir": "dist/app"
  },
  "exclude": [
    "node_modules"
  ]
}

的package.json:

{
  "name": "fallball",
  "version": "1.0.0",
  "scripts": {
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular/upgrade": "2.0.0-rc.5",
    "angular2-in-memory-web-api": "0.0.15",
    "core-js": "^2.4.0",
    "es6-shim": "^0.35.0",
    "@angular2-material/button": "^2.0.0-alpha.7-9",
    "@angular2-material/card": "2.0.0-alpha.7-9",
    "@angular2-material/core": "^2.0.0-alpha.7-9",
    "@angular2-material/toolbar": "^2.0.0-alpha.7-9",
    "@angular2-material/input": "2.0.0-alpha.7-9",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.12",
    "bootstrap": "^3.3.6",
    "gulp": "^3.9.1"
  },
  "devDependencies": {
    "concurrently": "^2.0.0",
    "gulp": "^3.9.1",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-typescript": "^2.13.6",
    "gulp-webserver": "^0.9.1",
    "lite-server": "^2.2.0",
    "typescript": "^2.0.0",
    "typings": "^1.3.1"
  }
}

请您澄清一下破损包裹的问题或我是否没有正确配置?谢谢!

1 个答案:

答案 0 :(得分:2)

您需要将typesript升级到2.0.0

我有同样的问题,我在这里问他们:https://github.com/angular/material2/issues/1208

希望对你有所帮助!