Skip to content

Allow exporting of types from module script #2555

@tzuleger

Description

@tzuleger

Describe the problem

In Svelte <=4, it was possible to export JSDOC custom types through the context="module" <script> tag by simply declaring the type.

In Svelte 5, it seems that types defined in the module script are not exported. At least, there's no clear way of doing it or no documentation on it.

Describe the proposed solution

Allow users to export types from the module script, to be imported from anywhere in the project.

$lib/components/MyComponent.svelte:

<script module>
/** @typedef {"myType"} MyType */
</script>
<script>
</script>

<!-- stuff -->

<style>
</style>

$lib/util/misc.js:

/** @import { MyType } from "$lib/components/MyComponent.svelte" */

/**
 * @param {MyType} x
 */
function stuff(x) {
  
}

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions