【发布时间】:2015-11-27 08:57:08
【问题描述】:
我只是从这里举了一个例子https://angular.io/guide/quickstart
我已按照快速入门手册完成所有操作。
但是当我的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:
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"sourceRoot": "/"
},
"exclude": [
"node_modules"
]
}
我将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 窗口中消失了
更新:
文件 -> 设置 -> 语言和框架 -> TypeScript 帮助切换到tsconfig.json。然后我通过禁用之前手动启用的 Typescript 观察程序解决了下一个问题:文件 -> 设置 -> 工具 -> 文件观察程序。现在有了这些设置,一切正常。
【问题讨论】:
-
我不确定这个issue 是否与您的问题有关,但值得一读。
-
我只是想补充一点,即使我的 tsconfig 中确实有正确的设置并且 WS 指向该配置文件,我最近也得到了这个。出于某种原因,我必须重新启动 WS,然后一切都恢复正常。
标签: webstorm angular typescript1.6