-
Notifications
You must be signed in to change notification settings - Fork 431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event type of midiInput.onmidimessage wrong #1571
Comments
I encountered this too. In my Chrome browser I can do this and it works. midiInput.onmidimessage = (msg) => {
const [status, note, velocity] = msg.data;
console.log(msg);
} But still typescript complains that:
I changed my code to the following and the typescript error is gone. midiInput.onmidimessage = (msg: MIDIMessageEvent) => {
const [status, note, velocity] = msg.data;
console.log(msg);
} |
@christiaanwesterbeek |
Just submitted a PR to fix this :) |
@fa-sharp |
@h-a-n-n-e-s Hmm, good question! I did assume it was automatic but maybe it isn't anymore. I did a little digging, and I think the last time the DOM types from this library were merged into TypeScript was this PR: microsoft/TypeScript#55798. So we might need to wait until TS 5.4 until the new types are merged? 🤷 |
@fa-sharp Oh, I see. Then lets wait for the next minor release! |
@fa-sharp In TS 5.4 it's merged! |
This
midiInput.onmidimessage = handleMIDIMessage;
with
handleMIDIMessage = (event:MIDIMessageEvent) => {...}
runs perfectly fine in the browser, but the TypeScript compiler throws this error:
Type '(event: MIDIMessageEvent) => void' is not assignable to type '(this: MIDIInput, ev: Event) => any'.
Types of parameters 'event' and 'ev' are incompatible.
Property 'data' is missing in type 'Event' but required in type 'MIDIMessageEvent'.
Shouldn't
midiInput.onmidimessage
have the type(this: MIDIInput, ev: MIDIMessageEvent) => any
instead of(this: MIDIInput, ev: Event) => any
?According to this
https://developer.mozilla.org/en-US/docs/Web/API/MIDIMessageEvent
it should.
Thanks!
The text was updated successfully, but these errors were encountered: