简体   繁体   中英

Constructor recognition in WebStorm (Node)

Very new to node development. I'm trying to define ES6 classes in WebStorm for a node application, but WebStorm doesn't seem to recognize the constructor keyword. Instead, it greys the word out, puts an "error squiggly" underneath it and tells me "Unused method constructor".

Am I doing something wrong? This seems like pretty simple functionality that should be supported.

截图

You will have to enable Javascript ECMA6 syntax support for it otherwise Webstorm will not recognize the new es6 keywords.

To enable ECMA6 support in webstorm , first click on the " File " menu on the top right hand corner. Then choose " Settings ". After which a big settings panel should appear, navigate to " Language & Framework " and select Javascript. On your left handside screen now select " ECMA6 " as the Java language version and hit "apply" at the bottom right.

Example: Webstorm设置面板

Output:

显示es6语法

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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