【问题标题】:WebStorm TypeScript definitions don't workWebStorm TypeScript 定义不起作用
【发布时间】:2017-09-23 17:23:17
【问题描述】:

我正在编写 three.js 代码并在设置中启用 TypeScript 定义。但是没有效果。我下载了它,检查了勾号,但什么也没发生。所有three.js 代码都带有下划线,WebStorm 写道没有导入。完整日志:

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.

我怎样才能修复它并正常编码,因为现在不可能?

【问题讨论】:

    标签: typescript three.js webstorm


    【解决方案1】:

    您可能正在加载带有常规<script> 标记的three.js。我相信您启用的声明不是“环境的”,它们描述了它的 commonjs 模块导出的内容,因此它不考虑您的设置具有全局可用的 three.js。

    您也许可以让 WebStorm 以某种方式将这些定义用作 ambient declarations,但预期的处理方式是 importing three.js via modules

    【讨论】:

    • 我不仅使用 script 标签,还使用 ​​TypeScript 定义。几个月前它有效,但现在无效。我都一样。附言可能,现在我需要添加导入注释,但我不记得,如何。
    • 如果您使用 TypeScript 编写代码,您所指的“导入注释”可能是 triple-slash directive。否则我不知道你之前是如何让它工作的,对不起:(
    猜你喜欢
    • 1970-01-01
    • 2017-11-08
    • 1970-01-01
    • 1970-01-01
    • 2015-02-10
    • 1970-01-01
    • 2021-10-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多