Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Why do I need to use the "type" keyword when importing types in Svelte?

$
0
0

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?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>