1

I am trying to get familiar with Angular2, TypeScript and ASP.NET 5. I am not very familiar with any of them so am following this tutorial:

https://www.youtube.com/watch?v=Zkesm9CUP_o&feature=youtu.be

My problem is that once I try to import from 'angular2/angular2' I am getting a build error in one of the Angular2 Typescript files.

So here is my folder structure:

enter image description here

Here is tsconfig.json

enter image description here

Here is gulpfile.js

enter image description here

and app.ts just contains the following:

import { Component, View, bootstrap } from 'angular2/angular2';

When I try to build, I get an error in di.d.ts. this is located in src\node_modules\angular2\src\core\metadata\di.d.ts

This is the error:

Error TS1110
Build: Type expected.

This is the line that the error refers to:

enter image description here

Any ideas why I'm getting this?

4
  • Upgrade your TypeScript to 1.7.3 Commented Dec 11, 2015 at 14:21
  • I already have version 1.7.3 Commented Dec 11, 2015 at 14:32
  • 1
    github.com/angular/angular/issues/5778 Commented Dec 11, 2015 at 14:39
  • Hmmm, so if I have Version 1.7.3 (which is what i'm told when I run tsc -v on the package manager console) why is it not recognising the this keyword Commented Dec 11, 2015 at 15:01

1 Answer 1

1

Looks like there's an error in the type definition file. Change

token: this;

to

token: AttributeMetadata;

and it should compile.

EDIT: This is indeed a feature, as @Eric Martinez commented, called "Polymorphic this Typing". Updating to TypeScript 1.7+ fixes the issue.

Sign up to request clarification or add additional context in comments.

1 Comment

It's not a bug, it's a feature (no, not a joke) introduced in TypeScript 1.7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.