Unable to import WebRTCAdaptor which is in js file from antmedia package in node modules folder in angular ts file

858 Views Asked by At

It is showing an error that :

Could not find a declaration file for the module 
'@antmedia/webrtc_adaptor/js/webrtc_adaptor.js'. 
'D:/web/node_modules/@antmedia/webrtc_adaptor/js/webrtc_adaptor.js' 
implicitly has an 'any' type.
  Try `npm i --save-dev @types/antmedia__webrtc_adaptor` 
if it exists or add a new declaration (.d.ts) file containing 
`declare module '@antmedia/webrtc_adaptor/js/webrtc_adaptor.js';`

Reference Image here: https://i.stack.imgur.com/JKQdR.png

Error

2

There are 2 best solutions below

0
Rahul Kumar On BEST ANSWER

Your error is self-explanatory.

In order to resolve your issue what you have to do is to create a folder named "antmedia__webrtc_adaptor" at the below path and create a file named "index.d.ts"

Inside the index.d.ts file you have to put the below code and save it.

inside index.d.ts paste the code declare module '@antmedia/webrtc_adaptor'

node_modules/@types/antmedia__webrtc_adaptor/index.d.ts

0
MaZZly On

The fix is apparently to import it like this for TypeScript support:

import { WebRTCAdaptor } from '@antmedia/webrtc_adaptor/dist/es';

The TypeScript hints are, however at the moment in a rather sad state: https://github.com/ant-media/Ant-Media-Server/issues/5066#issuecomment-1814299018