Skip to content

TS EventHandler param type not matches #12064

@MukjepScarlet

Description

@MukjepScarlet

Describe the bug

Missing declaration in interface for a non-undefined value event.data, for HTML input

Reproduction

<input on:input={getInputHandler(/^[01]*$/)}/>

const getInputHandler = (pattern: RegExp) => {return(event: Event & { data: string }) => { console.log(event.data); // typed text const inputElement = event.target as HTMLInputElement; // codes }};

Logs

Type '(event: Event & { data: string;}) => void' is not assignable to type 'FormEventHandler<HTMLInputElement>'.ts(2322)

System Info

System: OS: Windows 10 10.0.19045 CPU: (12) x64 Intel(R) Core(TM) i5-10400F CPU @ 2.90GHz Memory: 5.63 GB / 15.87 GB Binaries: Node: 20.12.0 - C:\Program Files\nodejs\node.EXE npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD pnpm: 9.0.5 - ~\AppData\Roaming\npm\pnpm.CMD Browsers: Edge: Chromium (126.0.2592.56) Internet Explorer: 11.0.19041.3636 npmPackages: svelte: ^4.2.12 => 4.2.15

Severity

annoyance

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions