Svelte TypeScript: Object is of type 'unknown'

Viewed 567

I'm trying to implement TypeScript in Svelte and have problem with event handlers in custom elements. When I write someting like:

<CustomComponent
        on:itemclick={() => dispatch("item", item)}
        on:doSometing={onDoSomethingHandler}
        on:doSomethingElse={onDoSomethingElseHandler}>
</CustomComponent>

And now the funny thing: the first two will generate error:

Object is of type 'unknown'

but not the last one. Of course all on: methods (itemClick, doSomething, doSomethingElse) are dispatched from CustomComponent. Whether I remove the first two handlers, the error will disappear. As far as I know the problem occurs only on custom components. But don't know why some works and some doesn't... Any idea?

1 Answers

Typescript support has been improved a lot (and updates are released often)

Check again using using the latest versions and if the issue still persists report the issue at https://github.com/sveltejs/language-tools

Related