WebStorm and Koa JS

I have been trying to setup WebStorm to correctly recognize NodeJS and Koa (and my other modules), however, whatever I have tried has failed. I've tried numerous suggestions I've found online (adding node_nodules in my JS Library), not exluding node_modules directory, etc. but none of this has helped. I've attached 4 images showing the issue and my setup.


 

 

 

 




Thanks

EDIT: I am using the latest version of WebStorm (2016.3.3)

0
6 comments

To avoid 'statement expected', etc. errors on arrow functions, please make sure to set JavaScript Language version (File | Settings | Languages & Frameworks | JavaScript) to 'ECMAScript 6'.

 

To get Koa methods resolved, please install Koa typescript stubs: inFile | Settings | Languages & Frameworks | JavaScript | Libraries, press Download.., then choose 'koa' from the list

0
Avatar
Permanently deleted user

Many thanks for the prompt reply Elena.

With regards to your first point, as you can see from the screenshots, I already have ECMAScript 6 enabled, so arrow functions shouldn't be showing errors, but they still are.

With regards to your second point, I already tried downloading the Koa TypeScript stubs but those didn't seem to help.

Any further help is greatly appreciated.

0

>as you can see from the screenshots, I already have ECMAScript 6 enabled,

 

No, I can't see this from your screenshots. I can see screenshots of Settings | Languages & Frameworks | JavaScript | Libraries and Settings | Languages & Frameworks | Node.js and NPM, but there is no screenshot of Settings | Languages & Frameworks | JavaScript page

 

>I already tried downloading the Koa TypeScript stubs but those didn't seem to help.

just checked - it indeed doesn't work with the most recent stubs for Koa 2.x because they define and export Application rather than Koa, so WebStorm can't match these stubs with required module:(

You can try using https://github.com/DefinitelyTyped/DefinitelyTyped/blob/types/koa/koa.d.ts instead

2
Avatar
Permanently deleted user

Excellent; those two suggestions seem to have sorted it out.

One last thing, I've noticed that under Settings | Languages & Frameworks | JavaScript, there's also a React JSX option. If I were to use both ECMAScript and React JSX within the same project, is there some sort of way to enable both?

Thanks

0

React JSX = ECMAScript 6 + JSX. So, if you need both, just choose React JSX as JavaScript Language version

0
Avatar
Permanently deleted user

I solved the auto-complete issue by installing typings:

https://www.npmjs.com/package/typings

 

sudo npm install typings --global

typings install koa --save

 

This creates a file in your project called typings.json with content:

{
"dependencies": {
"koa": "registry:npm/koa#2.0.0+20161018080506"
}
}
0

Please sign in to leave a comment.