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.52k stars 115 forks source link

Typescript with moduleResolution node16/nodenext is broken #318

Closed thovden closed 1 year ago

thovden commented 1 year ago

Description Describe the problem and how to reproduce it. If appropriate, include code samples, screenshots, error messages, etc.

Building a Typescript project using packages of "type": "module" and "moduleResolution": "nodenext" is broken because the types in the exports section is not specified.

The issue is discussed here: https://github.com/microsoft/TypeScript/issues/50466

Environment: Specify the environment where you are witnessing the problem:

Version 3.0.22, ESM, Node 16, Typescript, MacOS

Details Add any other information, context or details that could help track down the problem.

Since Typescript does not find types with the webmidi project, it reverts to the @types/webmidi, imported by the jzz package (a dependency of webmidi). These are probably old.

frontend/audio-ui/src/events/midi-event.ts:1:39 - error TS2306: File '/Users/torgeir/dev/tunasong/node_modules/@types/webmidi/index.d.ts' is not a module.

1 import type { NoteMessageEvent } from 'webmidi'
                                        ~~~~~~~~~

To reproduce:

  1. git clone https://github.com/thovden/webmidi-client-import-issue.git
  2. npm i
  3. tsc

The fix is easy and I will submit a PR for the fix shortly.