Language-tools: Typescript: Error when using `this` & `on:submit` together on `svelte:component`

Created on 4 Aug 2020  路  1Comment  路  Source: sveltejs/language-tools

Describe the bug
Using a construct like this:

<svelte:component this={directive.component} on:submit={handleSubmit} />

compiles and works perfectly but emits the following errors in svelte-check:

src/add/CompleteWord.svelte:41:84
Error: ',' expected. (ts)

src/add/CompleteWord.svelte:41:81
Error: Unexpected token. Did you mean `{'}'}` or `&rbrace;`? (ts)

src/add/CompleteWord.svelte:20:14
Hint: 'handleSubmit' is declared but its value is never read. (ts)

src/add/CompleteWord.svelte:41:84
Error: Cannot use namespace 'svelte' as a value. (ts)

To Reproduce

  • Setup a svelte project with standard typescript support
  • Create the following code
<script lang="ts">
  import Whatever from './Whatever.svelte';

  function handleSubmit() {
    console.log('test')
  }
</script>

<svelte:component this={Whatever} on:submit={handleSubmit}/>
  • execute npm run validate

Expected behavior
There should be no warnings or errors!

Screenshots
Screen Shot 2020-08-04 at 01 23 46

System (please complete the following information):

  • OS: OS-X
  • IDE: VSCode, Atom
  • Plugin/Package: svelte-check

Additional context
dceddia was already able to reproduce: https://discord.com/channels/457912077277855764/689494103380983930/739952039408304269

Fixed bug

Most helpful comment

That was fast 馃ぉ, works like a charm! Now you can expect more issues from me ;)...

>All comments

That was fast 馃ぉ, works like a charm! Now you can expect more issues from me ;)...

Was this page helpful?
0 / 5 - 0 ratings