编译包含Angular2导入的Typescript时在Webstorm中获取警告

编译包含Angular2导入的Typescript时在Webstorm中获取警告,webstorm,angular,typescript1.6,Webstorm,Angular,Typescript1.6,我只是举了个例子 我已经按照《快速入门手册》完成了所有工作。 但是当我的app.ts正在编译时,会在WebStorm控制台中收到警告 详情如下: 我使用的是Windows 8.1 x64、Webstorm 11.0.1 app.ts: import {bootstrap, Component} from 'angular2/angular2'; @Component({ selector: 'my-app', template: '<h1>My First Angul

我只是举了个例子

我已经按照《快速入门手册》完成了所有工作。 但是当我的
app.ts
正在编译时,会在WebStorm控制台中收到警告

详情如下:

我使用的是Windows 8.1 x64、Webstorm 11.0.1

app.ts

import {bootstrap, Component} from 'angular2/angular2';
@Component({
    selector: 'my-app',
    template: '<h1>My First Angular 3 App</h1>'
})
class AppComponent { }
bootstrap(AppComponent);
我把
tsconfig.json
文件放在
app
文件夹和根目录中

app.ts
实际上正在编译文件,但由于某些原因收到警告:

error TS1148: Cannot compile modules unless the '--module' flag is provided.
error TS2307: Cannot find module 'angular2/angular2'.
error TS1205: Decorators are only available when targeting ECMAScript 5 and higher.
error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.
我有打字机

我的文件夹结构

编辑:

在设置中设置
tsconfig.json
后,错误从
Typescript
窗口消失

但在
运行
输出和代码编辑器中出错:

没有关于
tsconfig.json的问题

更新:


文件->设置->语言和框架->类型脚本帮助切换到
tsconfig.json
。然后我通过禁用以前手动启用的Typescript监视程序解决了接下来的问题:文件->设置->工具->文件监视程序。现在有了这些设置,一切正常

您需要进入Webstorm中的文件->设置。然后在“设置”侧栏上转到“语言与框架”->“类型脚本”


然后在TypeScript设置页面中有一个单选按钮选项,用于
手动设置选项
使用tsconfig.json
。选择tsconfig选项,然后应用更改并关闭。那么webstorm应该知道在编译TypeScript时使用tsconfig选项。

它现在说:discovered
tsconfig.json
,但我有这样的文件,它没有使用它。另外,我刚刚添加了secton
“exclude”:[“node_modules”]
但是webstorm正在疯狂地构建
node_modules
,您是如何在tsconfig中构建
excludes
属性的?它是
编译器选项
之后的属性还是设置为
编译器选项
中的属性我刚刚重新启动了Webstorm。错误在
TypeScript编译器的控制台窗口中消失了。但是:在
Run
output窗口中会出现相同的警告,并且在
app.ts
窗口中突出显示了相同的错误。我认为我的
tsconfig.json
很好。刚刚更新了上面的内容。Webstrom说-
没有发现任何问题
,所以该文件很好。@MarcHarry,这与我安装的typescript 2.0+编译器的增加很好,而不是WebStorm捆绑的编译器(我有1.8.1)。在
设置->语言和框架->类型脚本
编译器
部分,将编译器版本更改为所需类型脚本的库。这就解决了我的问题。我不确定这是否与您的问题有关,但值得一读。我只是想补充一点,最近我得到了这一点,尽管我的tsconfig中有正确的设置,WS指向该配置文件。出于某种原因,我必须重新启动WS,然后一切又恢复正常。
error TS1148: Cannot compile modules unless the '--module' flag is provided.
error TS2307: Cannot find module 'angular2/angular2'.
error TS1205: Decorators are only available when targeting ECMAScript 5 and higher.
error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.