2017-09-22 72 views
0

我正在編寫three.js代碼並在設置中啓用了TypeScript定義。但是沒有效果。我下載了它,檢查了刻度但沒有發生任何事情。所有three.js代碼都有下劃線,WebStorm寫入沒有導入。完整的日誌:WebStorm TypeScript定義不起作用

Missing import statement less... (Ctrl+F1) Checks that all modules are referenced through import statements. Suggests inserting the import statement. When using libraries that define their own global symbols outside their visible JavaScript code (e.g. describe() in Mocha), it is recommended that you add the corresponding TypeScript type definition file as a JavaScript library in Preferences | Languages & Frameworks | JavaScript | Libraries.

如何解決它,代碼正常,因爲現在這是不可能的?

回答

0

您可能正在使用常規的<script>標記加載three.js。我相信您啓用的聲明不是「環境」,它們描述了它的commonjs模塊導出的內容,因此它不考慮全局可用的three.js設置。

您可能會以某種方式使WebStorm使用這些定義爲ambient declarations,但使用此工具的預期方式是importing three.js via modules

+0

我不僅使用腳本標籤,而且使用TypeScript定義。幾個月前它工作,但現在不行。我也一樣。附:可能,現在我需要添加導入評論,但我不記得,如何。 –

+0

如果您使用TypeScript編寫代碼,則所引用的「import comment」可能是[triple-slash指令](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html)。否則,我不知道你如何讓它工作之前,對不起:( – cvsguimaraes