audio
audio copied to clipboard
[BUG] Error: Cannot find name 'MediaStreamTrackAudioSourceNode'
🐞 Bug report
Description
When trying to run ng build on Angular 14 app:
in app.modules.ts
I added:
import { WebAudioModule } from '@ng-web-apis/audio';
and then added to imports:['WebAudioModule']
when running ng build
:
This error is displayed in the output.
Error: node_modules/@ng-web-apis/audio/sources/media-stream-track-source.d.ts:3:61 - error TS2304: Cannot find name 'MediaStreamTrackAudioSourceNode'.
✖ Failed to compile.
NOTE: I have also added @ng-web-apis/audio/polyfills
to my app's polyfills.js
:
import '@ng-web-apis/audio/polyfill';
Reproduction
- steps outlined above
Expected behavior
no error message and working Web Audio as expected from @ng-web-apis/audio
npm.
Versions
- OS: [Mac OS X]
- Browser [Chrome]
- Angular [14]
Additional context
I may just need clarification about how to implement this, but I thought I followed the somewhat vague instructions closely; please forgive my ignorance and teach me?
I'm not sure if this helps, but my editor displays a message when I hover over the import statement in polyfills.js:
Could not find a declaration file for module '@ng-web-apis/audio/polyfill'.
'/Users/clarkstacer/Projects/headlines-alpha/src/headlines/node_modules/@ng-web-apis/audio/polyfill.js'
implicitly has an 'any' type.
If the '@ng-web-apis/audio' package actually exposes this module,
try adding a new declaration (.d.ts) file containing `declare module '@ng-web-apis/audio/polyfill';`ts(7016)
Hey, sorry it took me so long to get to this issue. I've been really busy, I'll try to investigate/fix it this week.
@w3geekery can you create a small repository with reproduction?
@waterplea sure, I created an angular 14 skeleton app, then:
- ran
npm i @ng-web-apis/audio
- added import to app.module as described in initial report above
- added polyfill as described above
Public repo url: https://github.com/w3geekery/angular-14-ng-web-apis-audio-test/tree/master
Steps:
- clone above repo,
- run
npm install
, - run
ng build
to see error.
Ok. The idea of this library is to cover whole Web Audio API. This particular node, MediaStreamTrackAudioSourceNode
, is only implemented by Firefox. So there's a polyfill adding a stub so the code does not crash. At the time of writing, this type was in TypeScript, I guess now it got removed due to lack of browser support. I'll address this in the library when I have time to release Ivy distribution, in the meantime, you would have to use "skipLibCheck": true,
in your tsconfig
so that it doesn't throw an error at you.
All libs are being moved to monorepo and Ivy distribution, looks like this node is still only implemented in Firefox so the reasonable thing to do is to just remove it, which will be done in the upcoming release.