Skip to content

Commit b2bb264

Browse files
MaxGraeydcodeIO
authored andcommitted
Fix TypedArray.wrap definition (AssemblyScript#939)
1 parent 4f4dc7a commit b2bb264

File tree

1 file changed

+44
-13
lines changed

1 file changed

+44
-13
lines changed

std/assembly/index.d.ts

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,8 +1248,6 @@ declare abstract class TypedArray<T> implements ArrayBufferView {
12481248
[key: number]: T;
12491249
/** Number of bytes per element. */
12501250
static readonly BYTES_PER_ELEMENT: usize;
1251-
/** Wrap an ArrayBuffer */
1252-
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): ArrayBufferView;
12531251
/** Constructs a new typed array. */
12541252
constructor(length: i32);
12551253
/** The {@link ArrayBuffer} referenced by this view. */
@@ -1301,27 +1299,60 @@ declare abstract class TypedArray<T> implements ArrayBufferView {
13011299
}
13021300

13031301
/** An array of twos-complement 8-bit signed integers. */
1304-
declare class Int8Array extends TypedArray<i8> {}
1302+
declare class Int8Array extends TypedArray<i8> {
1303+
/** Wrap an ArrayBuffer */
1304+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int8Array;
1305+
}
13051306
/** An array of 8-bit unsigned integers. */
1306-
declare class Uint8Array extends TypedArray<u8> {}
1307+
declare class Uint8Array extends TypedArray<u8> {
1308+
/** Wrap an ArrayBuffer */
1309+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint8Array;
1310+
}
13071311
/** A clamped array of 8-bit unsigned integers. */
1308-
declare class Uint8ClampedArray extends TypedArray<u8> {}
1312+
declare class Uint8ClampedArray extends TypedArray<u8> {
1313+
/** Wrap an ArrayBuffer */
1314+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint8ClampedArray;
1315+
}
13091316
/** An array of twos-complement 16-bit signed integers. */
1310-
declare class Int16Array extends TypedArray<i16> {}
1317+
declare class Int16Array extends TypedArray<i16> {
1318+
/** Wrap an ArrayBuffer */
1319+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int16Array;
1320+
}
13111321
/** An array of 16-bit unsigned integers. */
1312-
declare class Uint16Array extends TypedArray<u16> {}
1322+
declare class Uint16Array extends TypedArray<u16> {
1323+
/** Wrap an ArrayBuffer */
1324+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint16Array;
1325+
}
13131326
/** An array of twos-complement 32-bit signed integers. */
1314-
declare class Int32Array extends TypedArray<i32> {}
1327+
declare class Int32Array extends TypedArray<i32> {
1328+
/** Wrap an ArrayBuffer */
1329+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int32Array;
1330+
}
13151331
/** An array of 32-bit unsigned integers. */
1316-
declare class Uint32Array extends TypedArray<u32> {}
1332+
declare class Uint32Array extends TypedArray<u32> {
1333+
/** Wrap an ArrayBuffer */
1334+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint32Array;
1335+
}
13171336
/** An array of twos-complement 64-bit signed integers. */
1318-
declare class Int64Array extends TypedArray<i64> {}
1337+
declare class Int64Array extends TypedArray<i64> {
1338+
/** Wrap an ArrayBuffer */
1339+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Int64Array;
1340+
}
13191341
/** An array of 64-bit unsigned integers. */
1320-
declare class Uint64Array extends TypedArray<u64> {}
1342+
declare class Uint64Array extends TypedArray<u64> {
1343+
/** Wrap an ArrayBuffer */
1344+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Uint64Array;
1345+
}
13211346
/** An array of 32-bit floating point numbers. */
1322-
declare class Float32Array extends TypedArray<f32> {}
1347+
declare class Float32Array extends TypedArray<f32> {
1348+
/** Wrap an ArrayBuffer */
1349+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Float32Array;
1350+
}
13231351
/** An array of 64-bit floating point numbers. */
1324-
declare class Float64Array extends TypedArray<f64> {}
1352+
declare class Float64Array extends TypedArray<f64> {
1353+
/** Wrap an ArrayBuffer */
1354+
static wrap(buffer: ArrayBuffer, byteOffset?: i32, length?: i32): Float64Array;
1355+
}
13251356

13261357
/** Class representing a sequence of values of type `T`. */
13271358
declare class Array<T> {

0 commit comments

Comments
 (0)