Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode add .js extension on import autocomplete

I am using VSCode and JavaScript ES6 Modules.

If I autocomplete an import like this import * as test from './test' the .js ending on ./test is missing and I have to add it manually.

Is there a setting to automatically add the extension?

like image 884
Hexception Avatar asked Jun 21 '20 18:06

Hexception


People also ask

How do I import an extension into VS Code?

You can browse and install extensions from within VS Code. Bring up the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of VS Code or the View: Extensions command (Ctrl+Shift+X). This will show you a list of the most popular VS Code extensions on the VS Code Marketplace.

How do I run a JavaScript file in Visual Studio Code?

1) Take VSCode 2) Right click on the file in left pane 3) Click "Reveal in explorer" from context menu 4) Right click on the file -> Select "Open with" -> Select "Choose another program" 5) Check box "Always use this app to open . js file" 6) Click "More apps" -> "Look for another app in PC" 7) Navigate to node.

What is auto import in VSCode?

Auto Import - ES6, TS, JSX, TSX (VSCode Extension) Automatically finds, parses and provides code actions and code completion for all available imports. Works with JavaScript (ES6) and TypeScript (TS). Forker from old repo vscode-extension-auto-import.

Are there any JavaScript extensions for Visual Studio Code?

JavaScript Extensions in Visual Studio Code JavaScript extensions for VS Code Visual Studio Code supports many features for JavaScript and Node.js development. The features that ship with the downloaded product are the core features: debugging, IntelliSense, code navigation, etc.

What features COME WITH VS Code for JavaScript development?

The features that ship with the downloaded product are the core features: debugging, IntelliSense, code navigation, etc. In addition, to these core features, you can install a large number of quality extensions to add features to VS Code for JavaScript development.

How do I extract JavaScript code from VSVs code?

VS Code includes some handy refactorings for JavaScript such as Extract function and Extract constant. Just select the source code you'd like to extract and then click on the lightbulb in the gutter or press (Ctrl+.) to see available refactorings.


1 Answers

Add this to your settings.json

"javascript.preferences.importModuleSpecifierEnding": "js",
"typescript.preferences.importModuleSpecifierEnding": "js",

Or in the Settings UI

auto imports js

like image 95
tHeSiD Avatar answered Oct 08 '22 02:10

tHeSiD