Skip to content

Cannot import TS types from Svelte components in .svelte.ts files #14884

Open
@Bilge

Description

@Bilge

Describe the bug

I cannot import types exported in a <script module lang="ts"> block in a .svelte.ts file (I can import them in other .svelte files).

TS complains that:

TS2614: Module '".svelte"' has no exported member 'ListRecord'. Did you mean to use 'import ListRecord from ".svelte"' instead?

Indeed, importing from "*.svelte" does actually work, but my editor thinks it's an error (and it sure does look wrong).

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-umuyfhqp?file=src%2Froutes%2FOtherTest.svelte.ts

Logs

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
    Memory: 7.56 GB / 11.69 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 22.12.0 - /run/user/1000/fnm_multishells/1080_1735405309856/bin/node
    Yarn: 1.22.22 - /run/user/1000/fnm_multishells/1080_1735405309856/bin/yarn
    npm: 10.9.0 - /run/user/1000/fnm_multishells/1080_1735405309856/bin/npm
  npmPackages:
    svelte: ^5.0.0 => 5.15.0
    webpack: ^5.11.0 => 5.97.1

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions