I want to access effectiveType and downlink properties of the NetworkInformation object.
I know that these properties may not exist depending on the browser, I'm checking that as follows:
const info: string[] = ['Downloading...'];
if ('connection' in window.navigator) {
info.push(`Connection Type: ${navigator.connection.effectiveType}`);
if ('downlink' in window.navigator.connection) {
info.push(`Speed: ${navigator.connection.downlink} MB/s`);
}
}
But the type contains only the type property. Though when I'm printing that object in the console it has all the properties I'm expecting:
What should I do to get past the typescript errors?
Property 'downlink' does not exist on type 'NetworkInformation'.ts(2339)
