Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1546

Right Typescript type for on:change handler in Svelte

$
0
0

I have this code:

<select class="form-control" on:change={pathChanged}>

The signature for pathChanged is:

function pathChanged(event: { target: HTMLSelectElement }) {

When I run that through tsc using npm run check, I get this error:

Error: Type '(event: { target: HTMLSelectElement; }) => void' is not assignable to type 'FormEventHandler<HTMLSelectElement>'.  Types of parameters 'event' and 'event' are incompatible.    Type 'Event & { currentTarget: EventTarget & HTMLSelectElement; }' is not assignable to type '{ target: HTMLSelectElement; }'.      Types of property 'target' are incompatible.        Type 'EventTarget | null' is not assignable to type 'HTMLSelectElement'.          Type 'null' is not assignable to type 'HTMLSelectElement'. (ts)<select class="form-control" on:change={pathChanged}>

What signature should pathChanged have?


Viewing all articles
Browse latest Browse all 1546

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>