rixo / svench

A lightweight workbench to develop your Svelte components in isolation
svench-docs.vercel.app
207 stars 6 forks source link

How to use Typescript in .svench file? #41

Open jacob-8 opened 2 years ago

jacob-8 commented 2 years ago

I'm wanting to use Types in my Svench file to set up the view but Vite will throw errors as soon as I start using typings like this:

<script lang="ts">
  import { View } from 'svench';
  import type { ICharacterArray } from '$lib/interfaces/character.interface';
  import { writable } from 'svelte/store';
  let characters = writable<ICharacterArray>({
    curious: [''],
    todo: [''],
    pronunciation: ['', ''],
    tone: [''],
    known: ['你', '好'],
  });
  import { setContext } from 'svelte';
  setContext('characters', characters);
  import Characters from './Characters.svelte';
</script>

<View>
  <Characters text="你" />
</View>