如何阻止WebStorm警告只在模板文件中调用的“未使用的方法”?

时间:2021-12-19 06:54:56

Is there a way for WebStorm to "see" the methods in my HTML and link them with their respective component class?

有没有办法让WebStorm“看到”我的HTML中的方法并将它们与各自的组件类链接起来?

Details

细节

I usually write my component controller in one file and the component template (html) in another file.

我通常在一个文件中编写组件控制器,在另一个文件中编写组件模板(html)。

When I do this, methods that are only used in the template are marked as "unused" by WebStorm, and they throw a warning.

当我这样做时,WebStorm将仅在模板中使用的方法标记为“未使用”,并且它们会发出警告。

For example, in the component ctrl I have a handleViewChange() method.

例如,在组件ctrl中我有一个handleViewChange()方法。

In the template file I have vm.handleViewChange();

在模板文件中我有vm.handleViewChange();

WebStorm warns me that handleViewChange is an unused method even though I have used it in the template.

WebStorm警告我,handleViewChange是一个未使用的方法,即使我已经在模板中使用它。


Please note: I am aware that I can suppress the warn for this particular statement. I would rather WebStorm recognized the method is actually used.

请注意:我知道我可以压制对此特定声明的警告。我宁愿WebStorm认识到实际使用的方法。

Particularly relevant with refactor-happy colleagues (or refactor-happy future me).

特别与重构快乐的同事(或重构 - 快乐的未来我)相关。


Edit #1

编辑#1

I have already enabled the AngularJS library in Webstorm settings, but it does not fix this particular issues.

我已经在Webstorm设置中启用了AngularJS库,但它没有解决这个特定问题。

如何阻止WebStorm警告只在模板文件中调用的“未使用的方法”?

1 个解决方案

#1


0  

Downloading angular TypeScript community stubs per suggestion at this post doesn't enable AngularJS support for your project. You need to have angular.js file (debug version, uncompressed!) in your project (either in your project directory or configured as JavaScript library) - normally it's enough to get Angular directives/methods recognized. See http://blog.jetbrains.com/webstorm/2014/03/angularjs-workflow-in-webstorm/, 'Include angular.js in Your Project' section.

在本文中按照建议下载角度TypeScript社区存根不会为您的项目启用AngularJS支持。您需要在项目中(在项目目录中或配置为JavaScript库)中拥有angular.js文件(调试版本,未压缩!) - 通常它足以识别Angular指令/方法。请参阅http://blog.jetbrains.com/webstorm/2014/03/angularjs-workflow-in-webstorm/,'在项目中包含angular.js'部分。

#1


0  

Downloading angular TypeScript community stubs per suggestion at this post doesn't enable AngularJS support for your project. You need to have angular.js file (debug version, uncompressed!) in your project (either in your project directory or configured as JavaScript library) - normally it's enough to get Angular directives/methods recognized. See http://blog.jetbrains.com/webstorm/2014/03/angularjs-workflow-in-webstorm/, 'Include angular.js in Your Project' section.

在本文中按照建议下载角度TypeScript社区存根不会为您的项目启用AngularJS支持。您需要在项目中(在项目目录中或配置为JavaScript库)中拥有angular.js文件(调试版本,未压缩!) - 通常它足以识别Angular指令/方法。请参阅http://blog.jetbrains.com/webstorm/2014/03/angularjs-workflow-in-webstorm/,'在项目中包含angular.js'部分。