Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng build error - Property 'requestMIDIAccess' does not exist

Tags:

angular

I am trying to build an Angular2 project, using the Web Midi API.

When runningng build, I am not able to complete the process due to certain errors thrown, specifically:

Error in bail mode: [default] /Users/JmsToh/GitHub/web-editor/web-editor/src/app/midi.service.ts:43:22 
Property 'requestMIDIAccess' does not exist on type 'Navigator'.

This comes from this part of the code:

if (navigator.requestMIDIAccess) {
  this.browserMidiCompatible = true;
  navigator.requestMIDIAccess({ sysex: false })
    .then(this.onMIDISuccess.bind(this), this.onMIDIReject.bind(this));
} else {
  alert("Platform not compatible");
}

The app runs fine on Chrome when running ng serve.Is there any way to get Angular2 to ignore the error when building?

like image 587
jmstoh Avatar asked Apr 06 '26 13:04

jmstoh


1 Answers

Add the necessary type definitions using:

npm install @types/webmidi

They should be automatically discovered after restarting tsc.

note: If after installing the library you see errors "Cannot find name Map", see this answer.

like image 107
Kos Avatar answered Apr 09 '26 01:04

Kos