Skip to content

Instantly share code, notes, and snippets.

@lukeed
Created April 2, 2020 00:35
Show Gist options
  • Save lukeed/65e270ea7d32ff9688340a34dd44a2e0 to your computer and use it in GitHub Desktop.
Save lukeed/65e270ea7d32ff9688340a34dd44a2e0 to your computer and use it in GitHub Desktop.
for swizec
// stick this somewhere in your local @types/** files
interface NetworkInformation extends EventTarget {
readonly downlink: number;
readonly downlinkMax?: number;
readonly effectiveType: 'slow-2g' | '2g' | '3g' | '4g';
readonly rtt: number;
readonly saveData: boolean;
readonly type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
onchange: EventListener;
}
interface Navigator {
connection: NetworkInformation;
}
@lukeed
Copy link
Author

lukeed commented Apr 2, 2020

It's not included in DOM types by default because it's technically still experimental. Even Chrome 80, for example, doesn't have the downlinkMax property, despite MDN (and other places) reporting that it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment