Skip to content

Commit ea2f915

Browse files
committed
Fix new ArrayBuffer type error in TypeScript 5.9
See https://devblogs.microsoft.com/typescript/announcing-typescript-5-9/#lib.d.ts-changes ``` $ npx tsc KaitaiStream.ts:136:5 - error TS2322: Type 'ArrayBufferLike' is not assignable to type 'ArrayBuffer'. Type 'SharedArrayBuffer' is not assignable to type 'ArrayBuffer'. Types of property '[Symbol.toStringTag]' are incompatible. Type '"SharedArrayBuffer"' is not assignable to type '"ArrayBuffer"'. 136 this._buffer = v.buffer; ~~~~~~~~~~~~ ```
1 parent 3caff2a commit ea2f915

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

KaitaiStream.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class KaitaiStream {
3232
* @param arrayBuffer ArrayBuffer to read from.
3333
* @param byteOffset Offset from arrayBuffer beginning for the KaitaiStream.
3434
*/
35-
public constructor(arrayBuffer: ArrayBuffer | DataView | number, byteOffset?: number) {
35+
public constructor(arrayBuffer: ArrayBuffer | DataView<ArrayBuffer> | number, byteOffset?: number) {
3636
this._byteOffset = byteOffset || 0;
3737
if (arrayBuffer instanceof ArrayBuffer) {
3838
this.buffer = arrayBuffer;
@@ -56,7 +56,7 @@ class KaitaiStream {
5656
private _byteLength = 0;
5757
private _byteOffset = 0;
5858
private _buffer!: ArrayBuffer;
59-
private _dataView!: DataView;
59+
private _dataView!: DataView<ArrayBuffer>;
6060

6161
public pos: number;
6262
public bits = 0;
@@ -124,14 +124,14 @@ class KaitaiStream {
124124
*
125125
* @returns The backing DataView.
126126
*/
127-
public get dataView(): DataView {
127+
public get dataView(): DataView<ArrayBuffer> {
128128
return this._dataView;
129129
}
130130
/**
131131
* Sets the backing DataView of the KaitaiStream object and updates the buffer
132132
* and byteOffset to point to the DataView values.
133133
*/
134-
public set dataView(v: DataView) {
134+
public set dataView(v: DataView<ArrayBuffer>) {
135135
this._byteOffset = v.byteOffset;
136136
this._buffer = v.buffer;
137137
this._dataView = new DataView(this._buffer, this._byteOffset);

0 commit comments

Comments
 (0)