简体   繁体   English

IntelliJ中的块打字稿自动完成

[英]Block Typescript Auto-complete in IntelliJ

I'm using IntelliJ 2018.2.4 Ultimate. 我正在使用IntelliJ 2018.2.4 Ultimate。

It seems that fairly recently the default auto-complete option when typing 'throw new Err' has changed from the standard Javascript Error class, to a typescript one. 似乎最近,键入“ throw new Err”时的默认自动完成选项已从标准Ja​​vascript Error类更改为打字稿。

在此处输入图片说明

Not only that, the standard Javascript error class doesn't even appear in the dropdown. 不仅如此,标准Javascript错误类甚至都不会出现在下拉列表中。

It makes no sense that it would suggest a Typescript class in a JS file, and even worse, no non-Typescript option at all. 它在JS文件中建议使用Typescript类是没有意义的,更糟糕​​的是,根本没有非Typescript选项。

After digging through the auto-completion settings and the auto-import settings, there doesn't seem to be any way to change this. 在浏览完自动完成设置和自动导入设置之后,似乎没有任何方法可以更改此设置。 It looks like it's sourcing this Typescript Error class from the Javascript plugin itself, so there is no way for me to eliminate the source without losing Javascript support. 看起来好像是从Javascript插件本身采购了此Typescript Error类,因此我无法在不失去Javascript支持的情况下消除源代码。

The only workaround I've found is implementing my own exception class with a different name, and using that everywhere. 我发现的唯一解决方法是用一个不同的名称实现我自己的异常类,并在各处使用它。 But that doesn't work for all cases, so I end up just typing out the entire thing every time, which seems dumb in a fancy IDE like this. 但这并不能在所有情况下都起作用,因此我最终每次都只输入整个内容,这在像这样的精美IDE中似乎很愚蠢。

Any ideas on how to fix this? 有想法该怎么解决这个吗? Or is this just a bug? 还是这只是一个错误?

This is the expected behavior - since 2017.3 IDEA uses the lib.*.d.ts files from Typescript repo to power its code completion for standard JavaScript objects and methods. 这是预期的行为-因为2017.3 IDEA使用lib.*.d.ts从文件打字稿回购来增强其代码完成标准的JavaScript对象和方法。 These files are now packaged inside IDE and updated regularly to keep libraries in sync with APIs changes. 这些文件现在打包在IDE中并定期更新,以使库与API更改保持同步。

Previously we used and maintained our own definition files that were incomplete and not always accurate. 以前,我们使用并维护了自己的定义文件,这些文件不完整且并不总是准确的。 Transition to the new definition files has made completion and quick docs more accuirate, complete and maintainable 过渡到新的定义文件使完成和快速文档更加准确,完整和可维护

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM