Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code Intellisense and JavaScript ES5

In Visual Studio Code (VSCode), I'm working with a legacy application that is JavaScript ES5. I've noticed that IntelliSense is not working for all typings that I have installed. Intellisense is working for global typings, but not working for external typings? Since this is legacy code, I rather not change the source .js files to get Intellisense to work.

Intellisense for global typings, such as angular and jquery, seem to work. But, IntelliSense for external typings are not working.

Here you can see that I have four typings installed. Angular and jQuery are installed as globals. LoDash and Ramda are installed as externals. I have a jsconfig.json file created; it's empty. By having the jsconfig.json file, IntelliSense works for the Angular and Jquery, but not for LoDash and Ramda.

VSCode Typings

In the next two images, you can see that Intellisense is working for Angular and jQuery.

VSCode Typings with Angular

VSCode Typings with jQuery

Now, I'm using LoDash, but IntelliSense is not working.

VSCode Typings with LoDash

If I import the LoDash library, then IntelliSense works. Since the code is legacy ES5 JavaScript and imports is not supported by ES5, using imports is not a viable option.

VSCode Typings with LoDash and imports

A good test would be to get IntelliSense working for LoDash. I would like to type "_." and have VSCode display a list of LoDash properties and methods without including any additional code in the source.

Does anyone know how to solve this issue? If so, please provide what worked for you.

Resources

  • VSCode - JavaScript - Rich Editing Support

BarDev

like image 595
Mike Barlow - BarDev Avatar asked Feb 10 '26 21:02

Mike Barlow - BarDev


1 Answers

As written in the official VS Code JS Intellisense documentation,

If you are using Visual Studio Code 1.8+, you can alternately explicitly list packages to acquire typings for in your jsconfig.json.

"typeAcquisition": {
    "include": [
        "lodash"
    ]
}

Now when you require or import lodash, Visual Studio Code will use the automatically downloaded typings files for the library to provide rich Intellisense. Most common JavaScript libraries have typings available.

like image 59
oldbam Avatar answered Feb 12 '26 16:02

oldbam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!