Skip to content

🐛 Svelte: Components could be promoted as import types #11389

Description

@akhansari

Environment information

Details
CLI:
  Version:                      2.5.8
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_DISTRIBUTION:                npm
  BIOME_LOG_PATH:                    unset
  BIOME_LOG_PREFIX_NAME:             unset
  BIOME_LOG_LEVEL:                   unset
  BIOME_LOG_KIND:                    unset
  BIOME_CONFIG_PATH:                 unset
  BIOME_THREADS:                     unset
  BIOME_WATCHER_KIND:                unset
  BIOME_WATCHER_POLLING_INTERVAL:    unset
  NO_COLOR:                     unset
  TERM:                         xterm-ghostty
  JS_RUNTIME_VERSION:           v26.7.0
  JS_RUNTIME_NAME:              node
  NODE_PACKAGE_MANAGER:         pnpm/11.3.0

Biome Configuration:
  Status:                       Loaded successfully.
  Path:                         biome.json
  Formatter enabled:            true
  Linter enabled:               true
  Assist enabled:               true
  VCS enabled:                  true
  HTML full support enabled:    true

Workspace:
  Open Documents:               0

What happened?

In Svelte, components are promoted as import types when there is a variable of that component type, even if it's used.

  • The linter raises a warn/err
  • The analyzer auto fix adds type, and breaks the build

Before:

<script lang="ts">
  import Modal from "$lib/components/Modal.svelte"

  let myModal: Modal

</script>

<Modal bind:this={myModal}>
</Modal>

After auto fix:

<script lang="ts">
  import type Modal from "$lib/components/Modal.svelte"

  let myModal: Modal

</script>

<Modal bind:this={myModal}>
</Modal>

Workaround:

  "linter": {
    "enabled": true,
    "rules": {
      "preset": "recommended",
      "style": {
        "useImportType": "off"
      }
    }
  },

https://biomejs.dev/playground/?lineWidth=100&indentStyle=space&trailingCommas=es5&indentWidth=4&semicolons=as-needed&indentScriptAndStyle=true&lintRules=all&tab=analyzer-fixes&pane=Diagnostics&code=PABzAGMAcgBpAHAAdAAgAGwAYQBuAGcAPQAiAHQAcwAiAD4ACgAgACAAaQBtAHAAbwByAHQAIABNAG8AZABhAGwAIABmAHIAbwBtACAAIgAkAGwAaQBiAC8AYwBvAG0AcABvAG4AZQBuAHQAcwAvAE0AbwBkAGEAbAAuAHMAdgBlAGwAdABlACIACgAKACAAIABsAGUAdAAgAG0AeQBNAG8AZABhAGwAOgAgAE0AbwBkAGEAbAAKAAoAPAAvAHMAYwByAGkAcAB0AD4ACgAKADwATQBvAGQAYQBsACAAYgBpAG4AZAA6AHQAaABpAHMAPQB7AG0AeQBNAG8AZABhAGwAfQA%2BAAoAPAAvAE0AbwBkAGEAbAA%2BAA%3D%3D&language=svelte

Expected result

Do not consider as import types when a component is used.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Activity

  1. added theissue type on Aug 18, 2026
  2. github-actions commented on Aug 18, 2026

    @github-actions
    Contributor

    ✅ Organic activity

    No automation signals detected in the analyzed events.

    View full analysis →

    This is an automated analysis by AgentScan

  3. dyc3 commented on Aug 18, 2026

    @dyc3
    Contributor

    Your playground doesn't reproduce the bug. I'm also confused because your biome rage output shows you have html full support enabled, so you shouldn't be seeing this bug in the first place.

  4. biome-cookie commented on Aug 18, 2026

    @biome-cookie

    Hello @akhansari, please provide a minimal reproduction. You can use one of the following options:

    • Provide a link to our playground, if it's applicable.
    • Provide a link to GitHub repository. To easily create a reproduction, you can use our interactive CLI via npm create @biomejs/biome-reproduction

    Issues marked with S-Needs repro will be closed if they have no activity within 3 days.

  5. akhansari commented on Aug 18, 2026

    @akhansari
    Author

    This is weird 🤔 I was able to reproduce it using the playground a few hours ago.

    I'll try to provide a repo sample.

  6. akhansari commented on Aug 18, 2026

    @akhansari
    Author

    @dyc3 You can reproduce the playground content by using --stdin-file-path.

    echo '<script lang="ts">
      import Modal from "$lib/components/Modal.svelte"
    
      let myModal: Modal
    </script>
    
    <Modal bind:this={myModal}>
    </Modal>' | pnpm biome check --write --stdin-file-path=+page.svelte

    The output should be similar to (type added):

    <script lang="ts">
        import type Modal from "$lib/components/Modal.svelte"
    
        let myModal: Modal
    </script>
    
    <Modal bind:this={myModal}> </Modal>

    Is this related to the extension check?

  7. added
    S-Bug-confirmedStatus: report has been confirmed as a valid bug
    and removed
    S-Needs reproStatus: needs a reproduction
    on Aug 18, 2026
  8. dyc3 commented on Aug 18, 2026

    @dyc3
    Contributor

    I was able to reproduce it, and it appears this really does only affect --stdin-file-path

  9. self-assigned this
    on Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-LinterArea: linterS-Bug-confirmedStatus: report has been confirmed as a valid bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions