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?

10 comments
Comment actions Permalink

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

0
Comment actions Permalink

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

0
Comment actions Permalink

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

0
Comment actions Permalink

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

0
Comment actions Permalink

Screenshot in my previous reply is taken when editing Typescript file

0
Comment actions Permalink

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
Comment actions Permalink

Try hitting Ctrl+Space twice

0
Comment actions Permalink

Unfortunately that didn't seem to work

1
Comment actions Permalink

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

0

Please sign in to leave a comment.