short: How to export/import JSDoc @typedef definitions in Svelte
The component which defines the type needs to do so in a <script context="module"> block (see Svelte docs on context="module")
// ReusableComponent.svelte
<script context="module">
/**
* An option object for <Select>
* @typedef {Object} SelectOption
* @property {string} value the value of this option
* @property {string} label the visible label to render
*/
</script>
// ... rest of the component
then, in the importing component you can refer to the type by importing it from the module:
short: How to export/import JSDoc @typedef definitions in Svelte
The component which defines the type needs to do so in a
<script context="module">
block (see Svelte docs on context="module")then, in the importing component you can refer to the type by importing it from the module: