svench icon indicating copy to clipboard operation
svench copied to clipboard

How to use Typescript in .svench file?

Open jacob-8 opened this issue 4 years ago • 0 comments

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>

jacob-8 avatar Aug 25 '21 21:08 jacob-8