lib Update Request
Configuration Check
My compilation target is ES2021 and my lib is ["DOM", "DOM.Iterable", "ES2021"]. TypeScript version is 4.9.5.
Missing / Incorrect Definition
The DataView constructor parameter type is incorrectly broad by accepting ArrayBufferLike because TypedArray's such as Uint8Array match the ArrayBufferLike type but are not valid parameters. I think the DataView constructor parameter should only accept ArrayBuffer | SharedArrayBuffer.
Sample Code
The following produces no error in TypeScript but does produce an error in Node 16, Chrome 109, and FireFox 111b1:
new DataView(new Uint8Array(32));
The runtime error is:
Uncaught TypeError: First argument to DataView constructor must be an ArrayBuffer
at new DataView (<anonymous>)
The correct code that does run is:
new DataView(new Uint8Array(32).buffer)
Documentation Link
lib Update Request
Configuration Check
My compilation target is
ES2021and my lib is["DOM", "DOM.Iterable", "ES2021"]. TypeScript version is 4.9.5.Missing / Incorrect Definition
The
DataViewconstructor parameter type is incorrectly broad by acceptingArrayBufferLikebecauseTypedArray's such asUint8Arraymatch theArrayBufferLiketype but are not valid parameters. I think theDataViewconstructor parameter should only acceptArrayBuffer | SharedArrayBuffer.Sample Code
The following produces no error in TypeScript but does produce an error in Node 16, Chrome 109, and FireFox 111b1:
The runtime error is:
The correct code that does run is:
Documentation Link
TypeErroris to be thrown if this is a detached buffer, i.e. without array buffer data)