Express types not showing up in autocomplete

I'm not getting Node.js Express autocompletions when I type. I've setup the JavaScript libraries (Language & Frameworks -> JavaScript -> Libraries) to use my node_modules which has @types/express installed as a devDependency. I've also installed @types/express from the JavaScript libraries preferences (Language & Frameworks -> JavaScript -> Libraries).

Note the above autocomplete suggestion just give me suggestions from `(typescript, dom)`, which are all irrelevant since i'm in a Node.js project. Not sure how to have those hidden/removed.

For reference, here is my tsconfig.json file:

Here's a look at my project's root directory structure. You can see the src directory is a resource root and the node_modules is a library root.

I'm able to get the Express types to show up in autocomplete suggestions (first option in the below screenshot) when I disable node_modules as being a project library. That doesn't seem right though since I would assume I would miss out on autocomplete from libraries in my node_modules.

4 comments
Comment actions Permalink

Works fine for me:

Note that I don't have @types/express library installed in Language & Frameworks -> JavaScript -> Libraries, having it in devDependencies is enough to get the completion work

Make sure that DOM lib is not included in your tsconfig.json - it's there by default if "lib" is not specified explicitly, see https://www.typescriptlang.org/docs/handbook/compiler-options.html:

If --lib is not specified a default list of libraries are injected. The default libraries injected are:
► For --target ES5: DOM,ES5,ScriptHost
► For --target ES6: DOM,ES6,DOM.Iterable,ScriptHost

0
Comment actions Permalink

Thanks for the tip regarding specifying "lib" in the tsconfig file, that resolved the issue with showing unnecessary libraries.

However, I still get an issue with the Express types not showing up. I've narrowed down the issue to it being related to the aws-sdk dependency messing things up. I've created a minimum reproducible example repo here: https://github.com/robertcoopercode/webstorm-typescript-issue

Any ideas why the aws-sdk package is "hi-jacking" the autocomplete types?

Here's the package.json for the minimum reproducible example:

{
"name": "admin-dashboard",
"version": "1.0.0",
"private": true,
"main": "index.ts",
"dependencies": {
"aws-sdk": "^2.866.0",
"express": "^4.16.2",
"typescript": "^4.2.4"
},
"devDependencies": {
"@types/express": "^4.17.9"
}
}
0
Comment actions Permalink

this happens because aws-sdk defines its own Request and Response modules... Submitted as https://youtrack.jetbrains.com/issue/WEB-51105, please follow it for updates

0
Comment actions Permalink

OK great, thanks for investigating and creating an issue!

0

Please sign in to leave a comment.