Skip to content

Easy to accidentally add imports for same component #462

@brunnerh

Description

@brunnerh

Describe the bug
If i have a file re-exporting components and then import from that, the import to the original file gets inserted in the script automatically when auto-completing the component name and using the first result.

To Reproduce

Example:

// Barrel file: /utility/index.ts
import Button from './button.svelte';
import TextField from './text-field.svelte';
import Dialog from './dialog.svelte';
...

export {
	Button,
	TextField,
	Dialog,
	...
}
<!-- Component /components/edit-dialog.svelte -->
<script type="text/typescript">
	import { TextField, Button, Dialog } from "../utility";
	import Dialog from "../utility/dialog.svelte"; // Gets inserted on auto-completing to Dialog tag in HTML below
</script>

<Dialog>...

Expected behavior
The existing named import is recognized and no additional import is added.

Screenshots

image

There are two Dialog entries, the first one adds the redundant import, the other one is for the existing named import. Ideally the first suggestion would not appear if the named import is already there.

System (please complete the following information):

  • OS: Windows 10, 64bit
  • IDE: VSCode
  • Plugin/Package: Svelte for VSCode

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions