Visual Studio Code Intellisense не работает для пакета НПМ


April 2019


699 раз


Я использую Визуальный код Студия 1.20.0 на Windows. Мой IntelliSense не работает правильно, например: Visual Studio код не в состоянии обнаружить, что youtubedl пакет имеет GetInfo метод. Будет ли сообщество иметь входы на то, что мне нужно сделать, чтобы получить IntelliSense работает правильно? Если нет, то как я могу просматривать пакет НПМ, чтобы найти различные методы, предоставляемые им (в .NET мы можем сделать то же самое с помощью объекта Explorer)?

введите описание изображения здесь

1 ответы


I'm also meet the same problem. And I'm using VS Code v1.24.0 on the macOS High Sierra.

referred from the page: VS Code automatically downloads and manages the type declaration files(*.d.ts) for JS with the ATA(Automatic Type Acquisition) feature, but it also not works for me.

So I find this: we can download the type declaration files manually with this kind command:

npm install --save-dev @types/name_for_the_ package

and you can choose to use the extension Types auto installer in VS Code to help you download type declaration files when you run npm install. maybe sometimes the Types auto installer will also not work, but you can download the types file manually anyway.

after you install the types files, you will get the intellisense again.

enter image description here

For the most part, type declaration packages should always have the same name as the package name on npm, but prefixed with @types/, but if you need, you can check out to find the package for your favorite library.

TypeScript-Declaration Files-Consumption

In some situation, you may need to add a jsconfig.json file to your project.

The presence of a jsconfig.json file in a directory indicates that the directory is the root of a JavaScript project. jsconfig.json specifies the root files and the options for the language features provided by the JavaScript language service. For common setups a jsconfig.json file is not required, however, there are situations when you will want to add a jsconfig.json.

Not all files should be in your JavaScript project (for example, you want to exclude some files from showing IntelliSense). This situation is common with front-end and back-end code.

Your workspace contains more than one project context. In this situation, you should add a jsconfig.json file at the root folder for each project.(the jsconfig.json can have no content.)

You are using the TypeScript compiler to down-level compile JavaScript source code.