5

I have gone through the following threads before posting this question.

Visual Studio Code: Intellisense not working

Visual Studio Code Intellisense not working for Javascript

I have Visual Studio version 1.26.1 on my Windows 10 laptop.

I am learning Node.Js, so I wanted to learn various functionalities in 'FS' module. I created a new file called 'app1.js' in Visual Studio Code, and wrote the following line of code.

fsObj = require('fs');

After this when I typed fsObj. to see what functions/properties are available under the fs object, I get a list with only two objects, which are not elements of the 'fs' module. I do not understand why IntelliSense is not showing the elemetns of 'fs' module. I am pasting a screen shot of the VS Code screen.

enter image description here

8
  • 1
    Those typings should be automatically downloaded, assuming you have node installed. You have "typescript.disableAutomaticTypeAcquisition": false, unchanged in your settings? And "editor.suggestOnTriggerCharacters": true, ? Those are the defaults which you don't want to change. Commented Aug 22, 2018 at 6:35
  • where are these settings? if these settings are in VS Code, how do I access it? Commented Aug 22, 2018 at 6:37
  • The gear icon in the lower left - then 'Settings'. Then you can 'Search Settings': you should find those two settings in the left panel (which is readonly) and not in the right panel at all if they haven't been changed. I also assume you have internet access so that vscode can download the files necessary for the intellisense. And you installed node? Sorry, basic questions just in case. Commented Aug 22, 2018 at 6:41
  • I have checked these settings and they are unchanged. The strange thing is that if I create a new folder and open that new folder in a new window of VS Code, then I am not facing this issue. But if I open the same folder (in which i see this issue) in a new VS code instance, then I still see this issue. Could this be related to something inside the folder? Commented Aug 22, 2018 at 6:51
  • I wouldn't think so, does putting const in front of the variable make any difference? It looks like it does for me. So: const fsObj = …. or let or var. Commented Aug 22, 2018 at 7:02

1 Answer 1

3

Without const, let or var before your variable fsObj, that variable has a 'global' scope. Something about that seems to prevent vscode from being able to assign the proper intellisense parameters to that variable. Adding one of those, like const, provides a different scope where the intellisense works. I cannot explain exactly what is preventing intellisense, perhaps the variable is bound to something higher in the scope chain that prevents it working.

In any case, failing to include const/let/var would result in an error if strict mode was used.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.