Skip to content

Commit 856d575

Browse files
committed
Use ArrayBufferLike instead of ArrayBuffer for reading/writing bytes
Prior to using `ArrayBufferLike`, TypeScript compilation errors in the generated output would occur: ``` src/generated/foobar.ts:1133:25 - error TS2345: Argument of type '(value: ArrayBuffer) => string' is not assignable to parameter of type 'StringLifter'. Types of parameters 'value' and 'bytes' are incompatible. Type 'Uint8Array<ArrayBufferLike>' is missing the following properties from type 'ArrayBuffer': maxByteLength, resizable, resize, detached, and 2 more. ``` Unfortunately, due to merging #197, these legitimate errors were also hidden. Ideally, we should investigate why the generated output has compilation issues and resolve them, and then revert #197.
1 parent 2449029 commit 856d575

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

typescript/src/ffi-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class RustBuffer {
4343
return new Uint8Array(this.arrayBuffer);
4444
}
4545

46-
readArrayBuffer(numBytes: number): ArrayBuffer {
46+
readArrayBuffer(numBytes: number): ArrayBufferLike {
4747
const start = this.readOffset;
4848
const end = this.checkOverflow(start, numBytes);
4949
const value = this.arrayBuffer.slice(start, end);
@@ -59,7 +59,7 @@ export class RustBuffer {
5959
return value;
6060
}
6161

62-
writeArrayBuffer(buffer: ArrayBuffer) {
62+
writeArrayBuffer(buffer: ArrayBufferLike) {
6363
const start = this.writeOffset;
6464
const end = this.checkOverflow(start, buffer.byteLength);
6565

0 commit comments

Comments
 (0)