Autocomplete and inspection issue using navigator.hid
I am facing an issue using the Web HID API. The inspection and documentation in Webstorm links to an Navigator object that has no hid property. However the hid attribute is listed in the documentation here https://developer.mozilla.org/en-US/docs/Web/API/Navigator/hid.
So as a result if I use the hid attribute the code inspection does complain about unresolved reference. In the following example hid.requestDevice
will be underlined. Is there something I can do about it, other then just disabling “unresolved reference” in the inspection profile and thus suppressing the issue? In an ideal case I want Webstorm to use an updated version of the Navigator object with hid attribute and related sub attributes, but my googlefu didn't turn up a solution.
const connectDevice = async () => {
const devices = await navigator.hid.requestDevice({filters:[]});
if (devices.length == 0)
return;
for (let device of devices)
await addDevice(device);
}
请先登录再写评论。
Library definitions the IDE uses for WEB API types resolving are provided by Microsoft; unfortunately
hid
property is not included inlib.*.d.ts
files provided by Microsoft, as it's an experimental API. See https://github.com/Microsoft/TypeScript/issues/21309#issuecomment-359110723Related ticket: https://github.com/microsoft/TypeScript/issues/47588
Thanks for the fast response, I will then suppress the issue for now