I'm coming from the React world, and I'm trying to learn Svelte 5.
Suppose I have the following file:
// types.tsexport interface Person { name: string;}
In React, I can import the Person
declaration as:
// Component.tsximport {Person} from './types';function Component() { return <></>;}
But in Svelte, I need to use the type
keyword in the declaration:
// Component.svelte<script lang="ts">import type {Person} from './types';</script>
If I don't use type
I see an error:
// Component.svelte<script lang="ts">import {Person} from './types';</script>
The requested module 'http://localhost:8080/src/types.ts' doesn't provide an export named: 'Person'
Why is type
needed?
Is there any configuration I can do to lift this requirement?