How to declare function parameter of type UInt8Array in TypeScript?
import * as fs from "fs";
fs.readFile(fileName, (err: string, data: UInt8Array) => {
if (err) {
return console.error(err);
}
console.log("file text: " + data.toString());
});
I'm having an error:
error TS2304: Cannot find name 'UInt8Array'
Thanks
Your error message indicates a typo, i.e.
error TS2304: Cannot find name 'UInt8Array'
complains about UInt8Array
. But the name you're looking for is probably Uint8Array, with a lowercase i
.
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