Element implicitly has an 'any' type because index expression is not of type 'number'
sangheraajit opened this issue · 3 comments
sangheraajit commented
We are getting the following error
Element implicitly has an 'any' type because index expression is not of type 'number'
method name
private async tryGetDevices() {
const mediaDevices = await navigator.mediaDevices.enumerateDevices();
console.log("mediaDevices",mediaDevices)
//return mediaDevices;
const devices = ['audioinput', 'audiooutput', 'videoinput'].reduce((options , kind) => {
return options[kind] = mediaDevices.filter(device => device.kind === kind);
}, [] as Devices);
return devices;
}
IEvangelist commented
Hi @sangheraajit - I think you might be able to solve this by adding this to the tsconfig.json.
{
"suppressImplicitAnyIndexErrors": true
}
sangheraajit commented
Hi,
Thanks that's works. But this seems workaround we should fix the issue.
IEvangelist commented
@sangheraajit
I always welcome pull requests, please submit one with your fix and I'll happily review it, and likely merge it in. Reference this issue when you do. If you're not able to submit a PR, we can close this issue as the code works.