Expose types for MediaRecorder API #44397
Closed
+85
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds type support for the MediaRecorder API available in all major browsers.
This API is a part of the MediaStream Recorder API. The interfaces for the Media Capture API (MediaStream, etc) are supported by TypeScript already.
There was a request some time ago to add these types but it was closed as unactionable: #34728
The spec for this API can be found here: https://w3c.github.io/mediacapture-record/
MDN Docs for it are here: https://developer.mozilla.org/en-US/docs/Web/API/MediaStream_Recording_API
It would be great to be able to use the types for this API without having to bring in an external dependency.
There is no Backlog issue for this request. I wanted to re-open the discussion around this while also providing the code for it to be fixed.
As a side note, it was kind of difficult to add these in such that they would fit into the rest of the
lib.dom.d.ts
file. At first glance, it seems to be ordered alphabetically, but that isn't actually the case. There's some kind of grouping applied to the interfaces, but it isn't clear to me what the intention is. Example: all of the *Options and *EventInit interfaces are grouped together alphabetically. Also, it's not clear to me why use a combination ofinterface
withdeclare var
to specify the constructor arguments instead of usingdeclare class
. I'm new to using TS though, so I might just be missing something obvious.