JS auto-import and completion of non-JS imports

In my web app (JavaScript, TypeScript, Webpack) I often import non-code assets, such as SVGs:

import MyIconSVG from "../../assets/icons/my-icon.svg"

However, unlike JS imports, IntelliJ:

1. Cannot generate the import by suggestion, ie typing "my-icon" somewhere

2. Cannot suggest the file at the end of the path, even though it can complete the path leading up to it

Can this be enabled in IntelliJ IDEA?

1
10 comments

No, such auto-imports are not supported. Auto-imports only work for JS/TS modules

0

What about file completion? Basically so that typing "../assets/icons/my" would suggest "my-icon.svg" for completion?

0

isn't it available? When hitting Ctrl+Space within `""`, I can see all files in completion list, including images:

0

It isn't... maybe it's a specific issue with TS auto-completion?

0

Screenshot in my previous reply is taken when editing Typescript file

0

Unfortunately this is what I get:

There are a whole bunch of .svg files in that folder, but it can't suggest or auto-complete them.

It can suggest and auto-complete the folders as usual:

0

Try hitting Ctrl+Space twice

0

Unfortunately that didn't seem to work

1

Have the same issue and reeeally want autocompletion for image paths in js/ts files.

0

Please sign in to leave a comment.