私はここから例をとりました 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ウォッチャーを無効にすることで、次の問題を解決しました:ファイル->設定->ツール->ファイルウォッチャー。これらの設定で、すべてが正常に動作しています。
Webstormの[ファイル]-> [設定]に移動する必要があります。そして、設定サイドバーで、言語とフレームワーク-> TypeScriptに移動します。
次に、TypeScript設定ページにSet options manually
またはUse tsconfig.json
のラジオボタンオプションがあります。 tsconfigオプションを選択し、変更を適用して閉じます。次に、Webストームは、TypeScriptをコンパイルするときにtsconfigオプションを使用することを知っている必要があります。