I am using below code just to see devices connected on usb port. Getting error "Property usb does not exist on type Navigator" at compile time when I run 'ng serve' command in command prompt.
ngOnInit() {
async () => {
let devices = await navigator.usb.getDevices();
devices.forEach(device => {
// Add |device| to the UI.
console.log(device);
});
}
}
yarn add -D @types/w3c-web-usb
or
npm install --save-dev @types/w3c-web-usb
Then, add the following directive at the top of your typescript file:
/// <reference types="w3c-web-usb" />
The best solution is to use @types/w3c-web-usb
typing package.
Add it to your project using either yarn:
yarn add --dev @types/w3c-web-usb
or npm
npm install --save-dev @types/w3c-web-usb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With