DEV Community

Matthias πŸ€–
Matthias πŸ€–

Posted on

2 1

JavaScript Import in VSCode IntelliSense

I try to set up a JavaScript project in Visual Studio Code.
Everything works fine, except IntelliSense. In my particular case, I added Styled Components and PropTypes, but both packages won't get suggested as import.

I already created a jsconfig.json file in my project root, but that didn't help either.

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "jsx": "react",
    "allowSyntheticDefaultImports": true
  },
  "exclude": ["node_modules", "public", ".cache"]
}
Enter fullscreen mode Exit fullscreen mode

Is there anything else I need to configure, or do I have to install an extension?

Would be awesome if anyone can help πŸ₯³

Top comments (4)

Collapse
 
t7yang profile image
t7yang β€’ β€’ Edited

code has no idea about the package inside node_modules, even in TypeScript, so you have to install types for those packages you need types declaration. You can manually install @types/styled-components, then code can provide auto import via its type definition.

img

Collapse
 
matthias profile image
Matthias πŸ€– β€’

Does that work in JavaScript projects?

Collapse
 
t7yang profile image
t7yang β€’

Yes, my screen capture is a JavaScript project not a TypeScript project.

Collapse
 
matthias profile image
Matthias πŸ€– β€’

Thank you!

The problem however is, that VSCode does not include the auto import options in the IntelliSense menu (see my screenshot in the article).

Gen AI apps are built with MongoDB Atlas

Gen AI apps are built with MongoDB Atlas

MongoDB Atlas is the developer-friendly database for building, scaling, and running gen AI & LLM appsβ€”no separate vector DB needed. Enjoy native vector search, 115+ regions, and flexible document modeling. Build AI faster, all in one place.

Start Free

Join the Algolia MCP Server Challenge: $3,000 in Prizes!

Explore the intersection of AI and search technology by building with the Algolia’s MCP Server. Three talented winners will be selected to share in our $3,000 prize pool!

Check out the challenge

DEV is bringing live events to the community. Dismiss if you're not interested. ❀️