Is there a way to enable intellisense for Javascript files in a Typescript project? If I import a function from a javascript package like this:
import foo from "js-package"
and I'm in index.js, I see the intellisense picking up JsDoc comments and listing the parameters taken by the function; if I'm in a .ts file however, I don't get any of this. How do I enable Js intellisense in .ts files, using VS Code?
EDIT: This is what happens:
Ironic, isn't it?
Visual Studio Code IntelliSense is provided for JavaScript, TypeScript, JSON, HTML, CSS, SCSS, and Less out of the box. VS Code supports word based completions for any programming language but can also be configured to have richer IntelliSense by installing a language extension.
IntelliSense shows you intelligent code completion, hover information, and signature help so that you can write code more quickly and correctly. VS Code provides IntelliSense for individual TypeScript files as well as TypeScript tsconfig. json projects.
You do not need any plugins. Just enable typeAcquisition in your tsconfig.json
by adding:
{
...
"typeAcquisition": {
"enable": true
}
}
This enables automatic detection and downloading of definition files for typescript. I often reload the window (restart vscode) when I change the settings, to make sure the settings have been read. This is not always necessary though.
This feature is disabled by default if using a tsconfig.json configuration file, but may be set to enabled as outlined further below). source
It was previously under typingOptions.enableAutoDiscovery, but was refactored to typeAcquisition.enable, as shown on this Github issue. You may still find references to on this websites. I find it harder to find information on typeAcquisition, but the schema proves its existence.
Missing tsconfig.json
? Create one following the top answer here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With