Eduard
Eduard

Reputation: 356

gulp typescript: error TS1005

I am creating angular2 typescript application. I am using angular/material2 in order to present better design. As for building the project - I am using gulp.

Problem statement: I changed @angular/router-deprecated to @angular/router and was forced to update other packages (@angular/core, @angular2-material etc)

After that gulp build stopped working and show the following errors:

.../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.

My gulp compile code looks as following:

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"
  }
}

Could you please clarify if the issue with broken packages or I did not configure something properly? Thank you!

Upvotes: 4

Views: 4304

Answers (1)

user3805731
user3805731

Reputation: 295

You need to upgrade typesript to 2.0.0

I have the same issue and I ask them here : https://github.com/angular/material2/issues/1208

Hope that help you !

Upvotes: 2

Related Questions