Skip to content

Imported svelte component lost type inference #16301

Closed
@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