microsoft / microsoft/TypeScript
RTCStatsReport should inherit or extend from Map
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
⚙ Compilation target
ESNEXT
⚙ Library
No idea why this item is mandatory
Missing / Incorrect Definition
RTCStatsReport is defined as follows:
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/RTCStatsReport) */
interface RTCStatsReport {
forEach(callbackfn: (value: any, key: string, parent: RTCStatsReport) => void, thisArg?: any): void;
}
As per documentation, RTCStatsReport is a Map-like object so it should include methods such as values(), entries() and members such as size. Note that it must NOT include delete(), clear() or set() since it's read-only (see doc links at the bottom).
However RTCStatsReport TypeScript definition only exposes forEach().
Sample Code
const pc = new RTCPeerConnection();
pc.createDataChannel('foo', { negotiated: true, id: 123, ordered: true });
const stats = await pc.getStats();
console.log('--- num stats:', stats.size);
for (const [id, stat] of stats) {
console.log('--- stat:', stat);
console.log('--- stats.get(id):', stats.get(id));
}
Produces:
--- num stats: 2
--- stat: {id: 'D37', timestamp: 1719306842612.802, type: 'data-channel', bytesReceived: 0, bytesSent: 0, …}
--- stats.get(id): {id: 'D37', timestamp: 1719306842612.802, type: 'data-channel', bytesReceived: 0, bytesSent: 0, …}
--- stat: {id: 'P', timestamp: 1719306842612.802, type: 'peer-connection', dataChannelsClosed: 0, dataChannelsOpened: 0}
--- stats.get(id): {id: 'P', timestamp: 1719306842612.802, type: 'peer-connection', dataChannelsClosed: 0, dataChannelsOpened: 0}
Documentation Link
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the RTCStatsReport interface shown in the issue and compare it with the linked MDN map-like API documentation. Confirm the read-only members and iteration behavior represented by the sample, while excluding delete(), clear(), and set(); done means the TypeScript definition exposes the documented behavior accurately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100