Skip to content

VSCode Organize Imports breaks when typing $props #2607

@coryvirok

Description

@coryvirok

Describe the bug

In certain situations, running VSCode's organize imports action will result in broken code.

E.g. Running organize imports on the following file produces broken code

<script lang="ts">
  import { page } from '$app/stores'

  let { foo }: { foo: string } = $props()
  console.log(foo, $page.url)
</script>

results in

<script lang="ts">
  import { page } from '$app/stores'
 { foo: string } = $props()
  console.log(foo, $page.url)
</script>

This does not happen if $props is typed using a type/interface:

<script lang="ts">
  import { page } from '$app/stores'

  interface Props {
    foo: string
  }

  let { foo }: Props = $props()
  console.log(foo, $page.url)
</script>

Nor does it happen if there are no imports.

Reproduction

<script lang="ts">
  import { page } from '$app/stores'

  let { foo }: { foo: string } = $props()
  console.log(foo, $page.url)
</script>

Expected behaviour

Unused imports are removed and the code is unmodified otherwise.

System Info

  • OS: MacOS
  • IDE: VSCode
  • Svelte for VSCode extension: v109.3.2

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy