Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 角度2:如何提供`--模块系统--experimentalDecorators`标志?_Typescript_Angular_Rubymine - Fatal编程技术网

Typescript 角度2:如何提供`--模块系统--experimentalDecorators`标志?

Typescript 角度2:如何提供`--模块系统--experimentalDecorators`标志?,typescript,angular,rubymine,Typescript,Angular,Rubymine,我在编译TypeScript文件时遇到问题: app/app.component.ts import {Component} from 'angular2/core'; @Component({ selector: 'my-app', template: '<h1>Messenger</h1>' }) export class AppComponent { } 在tsconfig.json中提供标志不起任何作用 tsconfig.json { "c

我在编译TypeScript文件时遇到问题:

app/app.component.ts

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: '<h1>Messenger</h1>'
})
export class AppComponent { }
在tsconfig.json中提供标志不起任何作用

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}
我的项目树:

.
├── app
├── node_modules
├── typings
├── application.js
├── messages.js
├── package.json
├── tsconfig.json
└── typings.json
我使用RubyMine 8作为IDE


我做错了什么?是否有其他方法提供我的标志?

如果您使用的是捆绑式TypeScript编译器,请转到
文件>设置>语言和框架>TypeScript

您可以单击
手动设置选项
单选按钮,并在
命令行选项
文本框中输入参数

这就是提供命令行参数的方式


Use tsconfig.json
在不提供任何命令行参数的情况下适用于我。

我可能遗漏了一些内容,但我认为您的app.component.ts的第一行中有两个错误

import {Component} from 'angular2/core';
应该是

import { Component } from '@angular2/core';

导入和花括号之间的空格以及angular2前面的“@”符号给我带来了很多痛苦。

一些想法:(1)确保您至少有typescript 1.5,这是在添加对tsconfig.json的支持时;(2)确保您没有从项目父文件夹调用tsc(tsc将向上而不是向下搜索tsconfig.json文件,(3)确保您没有使用命令行上的输入文件调用tsc(导致忽略tsconfig.json)。如果没有这些帮助,您能否提供一些有关如何执行tsc的详细信息?您使用的是哪种类型脚本编译器?与RubyMine或命令行捆绑的编译器?Angular 2早期测试版时,我问了这个问题,因此语法可能会更改。
import { Component } from '@angular2/core';