Skip to content

Autocomplete doesn't work when importing assets (non-js/ts/svelte files) #1254

@aradalvand

Description

@aradalvand

Describe the bug

I'm not really sure which repo I should post this issue in, so if this isn't the right place, please let me know.

In SvelteKit, you can of course import assets, stuff like .png, .jpg, or .svg files (there's an example of that in the official FAQ), and depending on the configuration, you could get the path to the file, or its contents (for example if you're using something like sveltekit-svg, by importing an SVG file you could get its content as a string).

This all works great, but the one issue that's been bothering me is that when you want to import, say an SVG file, VSCode's autocomplete doesn't show any of such files in its list of suggestions, while it does so for Svelte files or TS/JS files.

For instance, assuming you have a directory structure like so:

- src
    - lib
        - assets
            - logo.svg
            - avatar.png
            - someTypeScriptFile.ts
        - components
            - MyComp.svelte
    - routes
        - ...

When you want to import say the logo.svg file from the assets folder, this is what VSCode's list of suggestions looks like:

image

As you can see none of the .png, .svg, etc. files appear in the list.
Why is that? Isn't there any way to make this work?

In addition to that, when you reference a non-existent file, you don't get any red squiggly or anything, which isn't nice:

image

Note that I'm also using TypeScript in the project.

Thanks in advance.

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.feature requestNew feature or requestquestionA user questionupstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions