DEV Community

Discussion on: Add Intellisense for third-party JavaScript libraries in VS Code (it is not always automatic)

Collapse
 
tbroyer profile image
Thomas Broyer

🤔 I thought VSCode automatically downloaded them for you: code.visualstudio.com/docs/nodejs/...

Collapse
 
robole profile image
Rob OLeary • Edited

Hi Thomas,

You need a package.json or import statements in your JavaScript file for automatic acquisition. They mention it in the docs section you included.

Type declaration files are automatically downloaded and managed by Visual Studio Code for packages listed in your project's package.json or that you import into a JavaScript file.

So, if you are just including a library like GSAP in a script tag in your HTML, you don't get intellisense automatically. This is more likely to the case in front-end code. In a backend project, you probably have a package.json with dependencies, so you probably wouldn't encounter this!

I will add this to the article to give a complete explanation.

Collapse
 
tbroyer profile image
Thomas Broyer

Thanks for the precision.

I have to say I didn't get the distinction because I almost always reach for additional tools (ESLint, Prettier, Babel, some bundler like Parcel or Rollup) as soon as the project reaches a size where I also need a third-party library.

Thread Thread
 
robole profile image
Rob OLeary • Edited

Yes, that's why you never encountered it!

It kinda sucks for beginners who wouldn't be using NPM automatically. I often go without NPM for creative coding and small projects. It's not a great situation to be bound so tightly to the additional tools!

I updated the article with that distinction. Thanks for the feedback.