Imported svelte component lost type inference · Issue #16301 · sveltejs/svelte · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Imported svelte component lost type inference #16301

Open
@absolutejs

Description

@absolutejs

Describe the bug

When importing a Svelte component into a typescript file I expect the resulting import to have Component type with the proper inferred props. As of 7/3 when I updated my VSCode plugin for svelte it now loses type inference and has type any. I suspect this may be related to #16270 but I'm not positive.

import SvelteExample from './svelte/pages/SvelteExample.svelte';
/*(alias) type SvelteExample = any
(alias) const SvelteExample: any*/

The reason this is useful is I can import the component, then pass it to a function. By passing it to a function I can pass the props to the function in a type safe manner. My use case for this is Svelte page handlers where the user can input a page and props and a web stream will be returned for the html.

Reproduction

To reproduce this bug download the example repository at https://github.com/absolutejs/absolutejs. Open this project in VSCode and open example/server.ts. Notice that SvelteExample has type any as an import and no longer has type safety for its props.

Logs

System Info

System:
    OS: Linux 6.6 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (14) x64 Intel(R) Core(TM) Ultra 7 155U
    Memory: 11.66 GB / 15.34 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v22.14.0/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
    bun: 1.2.17 - ~/.bun/bin/bun
  npmPackages:
    svelte: 5.35.2 => 5.35.2

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      TMZ Celebrity News – Breaking Stories, Videos & Gossip

      Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

      Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

      🎥 Watch TMZ Live

      TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.