Skip to content

Type import with same name as variable causes migration error #3035

Description

@brunnerh

Describe the bug

Type imports can have the same name as a local variable, but this causes errors when using the "Migrate Component to Svelte 5" command.

There also is a secondary issue that one can get false positive errors from the command if the installed Svelte version was to old/non-existent when the command was first called on the file. So instead of getting a @migration-task Error ... in the code, an error notification pops up that claims that the Svelte version does not support migration, even though it works on other components.

Reproduction

// test.ts
export type Thing = string;
<script lang="ts">
    import type { Thing } from './test';

    export let Thing: Thing = 'hi';
</script>

{Thing}

(Import is important, a local type definition does not cause the error.)

Expected behaviour

Migration works.

System Info

  • OS: Win 11
  • IDE: VS Code 1.121.0
  • Extension: 110.0.0

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions