Closed master30f closed 1 year ago
The EventEmitter and Listener classes are actually part of the djipevents package which is separate from WEBMIDI.js. In such a case, I'm not sure what the proper way to do things is. To be honest, I'm not very familiar with TypeScript. Ideas?
I found that adding export
before the class declaration in webmidi.cjs.d.ts
like so:
export declare class Listener {
...
}
works as a very hackish work-around, but I'm not familiar with your build system (or any build systems in general as I've never made a ts library before) so I have no idea how to actually fix it.
Edit: I found out that in your case the declaration file is not auto generated, so applying the above fix to webmidi.d.ts
might work.
As you noted, the Listener
and EventEmitter
classes are already declared in webmidi.d.ts
but they are not exported. It was done this way because these two classes are actually part of a separate package called djipevents
. If there is no harm in exporting them from webmidi.d.ts
, I could easily do it. However, not being too familiar with TypeScript, I'm not sure of the implications. Could it cause unforeseen issues?
As far as I know it should not cause any harm, as the declarations in webmidi.d.ts
are just typings -- they only tell the typescript compiler how the data structures "look" and will not collide with / override the javascript definitions.
This has been pushed in release v3.0.22. Thanks for suggesting this enhancement.
Description The Listener class (and maybe some others) are not being exposed to the user, so it's impossible to use them in type definitions. Example:
Environment:
Details None