diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 18a9bacccd..d7ebab4fd0 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -379,7 +379,7 @@ declare var Buffer: { * Creates a new Buffer using the passed {data} * @param data data to create a new Buffer */ - from(data: any[] | string | Buffer | ArrayBuffer /*| TypedArray*/): Buffer; + from(data: any[] | string | Buffer | ArrayBuffer | Uint8Array /*| TypedArray*/): Buffer; /** * Creates a new Buffer containing the given JavaScript string {str}. * If provided, the {encoding} parameter identifies the character encoding. diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index d6751541b9..d428cf8753 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -432,10 +432,13 @@ function bufferTests() { // String const buf3: Buffer = Buffer.from('this is a tést'); // ArrayBuffer - const arr: Uint16Array = new Uint16Array(2); - arr[0] = 5000; - arr[1] = 4000; - const buf4: Buffer = Buffer.from(arr.buffer); + const arrUint16: Uint16Array = new Uint16Array(2); + arrUint16[0] = 5000; + arrUint16[1] = 4000; + const buf4: Buffer = Buffer.from(arrUint16.buffer); + const arrUint8: Uint8Array = new Uint8Array(2); + const buf5: Buffer = Buffer.from(arrUint8); + const buf6: Buffer = Buffer.from(buf1); } // Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])