【发布时间】:2022-11-03 06:17:39
【问题描述】:
我有这个代码:
<select class="form-control" on:change={pathChanged}>
pathChanged 的签名是:
function pathChanged(event: { target: HTMLSelectElement }) {
当我使用npm run check 运行tsc 时,我收到此错误:
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}>
pathChanged 应该有什么签名?
【问题讨论】:
标签: typescript svelte