From 16a6b86122b742ba48637d58379d1c401ea206b7 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Fri, 21 Oct 2022 06:46:57 +0300 Subject: fix(ext/ffi): Use BufferSource for FFI buffer types (#16355) Potential fix for type-code mismatch in FFI buffer types. The code supports ArrayBuffers, but types only reflect TypedArray support. There's also an existing type for this sort of stuff: `BufferSource`. (Although, it uses `ArrayBufferView` which doesn't actually connect with the TypedArray interfaces specifically, but it's just a type inheritance difference and nothing more.) --- test_ffi/tests/ffi_types.ts | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'test_ffi/tests') diff --git a/test_ffi/tests/ffi_types.ts b/test_ffi/tests/ffi_types.ts index 76c013a8f..e2054cfe1 100644 --- a/test_ffi/tests/ffi_types.ts +++ b/test_ffi/tests/ffi_types.ts @@ -157,12 +157,12 @@ result2.then((_1: Deno.PointerValue) => {}); const result3 = remote.symbols.method18(); // @ts-expect-error: Invalid argument -let r3_0: Deno.TypedArray = result3; +let r3_0: Deno.BufferSource = result3; let r3_1: Deno.UnsafePointer = result3; const result4 = remote.symbols.method19(); // @ts-expect-error: Invalid argument -result4.then((_0: Deno.TypedArray) => {}); +result4.then((_0: Deno.BufferSource) => {}); result4.then((_1: Deno.UnsafePointer) => {}); const fnptr = new Deno.UnsafeFnPointer( @@ -345,19 +345,6 @@ type AssertNotEqual< $ = [Equal] extends [true] ? never : Expected, > = never; -type TypedArray = - | Int8Array - | Uint8Array - | Int16Array - | Uint16Array - | Int32Array - | Uint32Array - | Uint8ClampedArray - | Float32Array - | Float64Array - | BigInt64Array - | BigUint64Array; - type __Tests__ = [ empty: AssertEqual< { symbols: Record; close(): void }, @@ -371,7 +358,7 @@ type __Tests__ = [ { symbols: { pushBuf: ( - buf: TypedArray | null, + buf: BufferSource | null, ptr: Deno.PointerValue | null, func: Deno.PointerValue | null, ) => void; @@ -391,7 +378,7 @@ type __Tests__ = [ { symbols: { pushBuf: ( - buf: TypedArray | null, + buf: BufferSource | null, ptr: Deno.PointerValue | null, func: Deno.PointerValue | null, ) => Deno.PointerValue; -- cgit v1.2.3