2015-11-27 10 views
14

Angular2の輸入を含ま活字体をコンパイルするときWebstormで警告を取得。 app.tsがコンパイルされているときにWebStormコンソールで警告が表示される。ここで私は、すべてのクイックスタートマニュアルに従ってここ<a href="https://angular.io/guide/quickstart" rel="nofollow noreferrer">https://angular.io/guide/quickstart</a></p> <p>私がやったから例を取っ

は詳細です:

私は、Windows 8.1のx64、Webstorm 11.0.1

app.ts日午前:私はtsconfig.jsonファイルを置いた

{ 
    "compilerOptions": { 
    "target": "ES5", 
    "module": "commonjs", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": false, 
    "sourceRoot": "/" 
    }, 
    "exclude": [ 
    "node_modules" 
    ] 
} 

import {bootstrap, Component} from 'angular2/angular2'; 
@Component({ 
    selector: 'my-app', 
    template: '<h1>My First Angular 3 App</h1>' 
}) 
class AppComponent { } 
bootstrap(AppComponent); 

tsconfig.jsonappフォルダーそして根の中にある。

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. 

私が持っているタイピングは

マイフォルダ構造

enter image description here

編集が含まれていました。

私は設定でtsconfig.jsonを設定した後にエラーがTypescriptウィンドウ

enter image description here

から姿を消したが、Run出力とコードエディタでのエラーを得た: enter image description here

enter image description here

tsconfig.jsonでは問題がありません

更新日:

ファイル - >設定 - >言語&フレームワーク - >タイプスクリプトtsconfig.jsonに切り替えるのを助けた。それから、手動で以前に有効にしたTypescriptウォッチャーを無効にすることで、次の問題を解決しました。ファイル - >設定 - >ツール - >ファイルウォッチャー。今これらの設定ですべてが正常に動作しています。

+0

この[問題](https://github.com/angular/angular/issues/5248)があなたの問題に関連しているかどうかはわかりませんが、読んだだけでは分かりません。 –

答えて

36

「Webstorm」の「ファイル」 - >「設定」に移動する必要があります。設定サイドバーで、言語&フレームワーク - > TypeScriptに移動します。

次に、TypeScript設定ページにSet options manuallyまたはUse tsconfig.jsonのラジオボタンオプションがあります。 tsconfigオプションを選択し、変更を適用して閉じます。その後、WebstormはTypeScriptをコンパイルするときにtsconfigオプションを使用することを知っている必要があります。

+5

私はちょうどそれをしましたが、コンソールにまだ警告があります... – sreginogemoh

+1

これは今言う: 'tsconfig.json'を発見しましたが、私はそれを使っていないというファイルを持っています。また、私はsecton '' exclude ': '' node_modules' ''を追加しました。しかしwebstormは狂気のように' node_modules'を構築しようとしています – sreginogemoh

+0

tsconfigでどのように 'excludes'プロパティーを構造化しましたか? 'compilerOptions'の後のプロパティか、' compilerOptions'の中のプロパティとして設定されています –