Search code examples
webstorm

Autocomplete for import keyword is ommiting file extension


I am having a problem with WebStorm auto complete when using import keyword in JavaScript.
You can see an example here: https://i.gyazo.com/95adbf84c964663f715fc069ba1e1e8a.mp4

Basically when I auto complete following code:

import {loadLevel, loadSprite} from './loaders';  

It doesn't add a file extension to loaders, which should look like this:

import {loadLevel, loadSprite} from './loaders.js';  

I am using latest WebStorm version, I also tried to Invalidate cache and restarted IDE.
I am using JavaScript ES6 version in settings.
There are no other files called loaders with different extension anywhere else in my project.

If you need any more info, let me know.

Thanks


Solution

  • WebStorm supports completing file name with extension (when using completion in the from part). To enable completing file name with extension, set registry key commonjs.complete.required.filename.with.extension to true :

    • Open Help | Find Action... dialog
    • Type Registry, find Registry item in dropdown list and press Enter
    • Find commonjs.complete.required.filename.with.extension there, tick the checkbox

    But this hidden option doesn't affect auto-imports, so, when auto-creating import statement from reference, extension won't be added - WEB-28741