audio icon indicating copy to clipboard operation
audio copied to clipboard

[BUG] Error: Cannot find name 'MediaStreamTrackAudioSourceNode'

Open w3geekery opened this issue 2 years ago • 6 comments

🐞 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

w3geekery avatar Sep 12 '22 03:09 w3geekery

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?

w3geekery avatar Sep 12 '22 03:09 w3geekery

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)

w3geekery avatar Sep 12 '22 15:09 w3geekery

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.

waterplea avatar Sep 19 '22 19:09 waterplea

@w3geekery can you create a small repository with reproduction?

waterplea avatar Sep 28 '22 12:09 waterplea

@waterplea sure, I created an angular 14 skeleton app, then:

  1. ran npm i @ng-web-apis/audio
  2. added import to app.module as described in initial report above
  3. added polyfill as described above

Public repo url: https://github.com/w3geekery/angular-14-ng-web-apis-audio-test/tree/master

Steps:

  1. clone above repo,
  2. run npm install,
  3. run ng build to see error.

w3geekery avatar Sep 28 '22 15:09 w3geekery

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.

waterplea avatar Sep 29 '22 16:09 waterplea

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.

waterplea avatar May 15 '23 08:05 waterplea