djipco / webmidi

Tame the Web MIDI API. Send and receive MIDI messages with ease. Control instruments with user-friendly functions (playNote, sendPitchBend, etc.). React to MIDI input with simple event listeners (noteon, pitchbend, controlchange, etc.).
Apache License 2.0
1.53k stars 115 forks source link

removing input listeners #228

Closed glend1 closed 2 years ago

glend1 commented 2 years ago

I though this might have been a typescript error that would have magically got solved with the rest of the issues but it hasn't.

here is my code, this appears to be a typescript issue again;

WebMidi.inputs.forEach(e => {
    e.removeListener()
})

VSCode is telling me Expected 2-3 arguments, but got 0

I have created a new file, in my project, since that has been a point of contention before and;

import { WebMidi } from 'webmidi'

WebMidi.inputs[0].removeListener()
WebMidi.inputs[0].removeListener("noteon")
WebMidi.inputs[0].removeListener("noteon", (e) => { console.log(e)}) //doesn't give the error

This appears to not match the documentation, I don't know if the documentation is wrong or the code. Can you take a look at whats happening here?

EDIT: the code works but isn't validating with typescript. so its a typescript error.

djipco commented 2 years ago

You are right. There was an error in the .d.ts file with regards to removeListener(). It has been fixed in v3.0.13. Once again, thanks for reporting.