Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Declare UInt8Array variable in TypeScript

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

like image 664
Vladimir Melekh Avatar asked Aug 01 '16 21:08

Vladimir Melekh


1 Answers

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.

like image 97
Frederick Nord Avatar answered Sep 20 '22 23:09

Frederick Nord