I’d like to call getUserMedia from TypeScript, something like:
return navigator.getUserMedia()
However, TypeScript’s definition of Navigator (in lib.d.ts) doesn’t contain getUserMedia.
How do I work around? Should I be modifying lib.d.ts? Where do I make this change?
The current practice for this is to add to the interface, rather than edit the lib.d.ts file.
You can add to the interface in your TypeScript file and when the lib.d.ts is updated, the compiler will tell you that you no longer need it. I have put it extra white-space to make the different parts of the declaration easier to read and I’ve added a sample call below the interface.
I would make this change in the class that uses
getUserMedia. And I would try to restrict all usages ofgetUserMediato that class.