Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

importin typescript types/interfaces with svelte components triggers compiler error while importing them

I have a Svelte project that uses Vite as the build tool, and I’m trying to import a TypeScript interface(toDo) in a Svelte component. However, I’m getting an error when I try to compile the component

Here’s what my Svelte component looks like:

<script type="ts">
   import { toDo } from "./todos.store";
</script>

in this code snippet toDo is the type assigned to a toDoItem.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any ideas on what might be causing this error and how I can fix it?

>Solution :

Change your type='ts' to lang='ts', and if you’re importing a type it’s good practice to specify that such like:

import type { toDo } from "./todos.store";
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading