2017-09-22 93 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