I've just started learning about angular 2 and all the technologies that come with it and I'm trying to use gulp-jspm-build to create minified and "compiled" versions of my .ts files. The problem is I get this error and I don't know how to solve it. Could i get some assistance pls
SyntaxError: app/menu/component.ts: Unexpected token (8:0)
6 | import {OnInit} from "@angular/core/metadata/lifecycle_hooks";
7 |
> 8 | @Component({
| ^
9 | selector: '[menu]',
10 | templateUrl: 'app/menu/template.html',
11 | })
at Parser.pp.raise...
I dont have a typings.json file, does that have to do with it?
答案 0 :(得分:0)
首先,您需要告诉您的转换器您使用装饰器,因为它们本身不受支持(在tsconfig.json或grunt / gulp配置中):
{
"compilerOptions": {
...
"experimentalDecorators": true, <- here
然后你必须从angular:
导入组件类 import { Component } from '@angular/core';
更多信息here。
关于typings.json的问题,它没有关系。 typing(npm install -g typings
)使用此文件来管理打字稿类型。它可以帮助您的转换器和IDE了解您使用ES6或ES5编写的外部库(没有打字稿类型)。
有关详细信息,请参阅here。