From 438c727620efe9c0f43f8ecaf5e44ee8f3f00624 Mon Sep 17 00:00:00 2001 From: Andriy Kashcha Date: Wed, 15 Apr 2020 08:31:26 -0700 Subject: [PATCH 1/2] Changed array type As discussed in https://github.com/toji/gl-matrix/issues/386 --- src/types.d.ts | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/types.d.ts b/src/types.d.ts index 12734450..f47b4249 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,22 +1,27 @@ +interface IndexedCollection { + readonly length: number; + [index: number]: number; +} + // prettier-ignore declare type mat2 = | [number, number, number, number] - | Float32Array; + | IndexedCollection; // prettier-ignore declare type mat2d = | [number, number, number, number, number, number] - | Float32Array; + | IndexedCollection; // prettier-ignore declare type mat3 = | [number, number, number, number, number, number, number, number, number] - | Float32Array; + | IndexedCollection; // prettier-ignore declare type mat4 = @@ -24,19 +29,19 @@ declare type mat4 = number, number, number, number, number, number, number, number, number, number, number, number] - | Float32Array; + | IndexedCollection; -declare type quat = [number, number, number, number] | Float32Array; +declare type quat = [number, number, number, number] | IndexedCollection; // prettier-ignore declare type quat2 = | [number, number, number, number, number, number, number, number] - | Float32Array; + | IndexedCollection; -declare type vec2 = [number, number] | Float32Array; -declare type vec3 = [number, number, number] | Float32Array; -declare type vec4 = [number, number, number, number] | Float32Array; +declare type vec2 = [number, number] | IndexedCollection; +declare type vec3 = [number, number, number] | IndexedCollection; +declare type vec4 = [number, number, number, number] | IndexedCollection; // prettier-ignore declare type ReadonlyMat2 = @@ -44,7 +49,7 @@ declare type ReadonlyMat2 = number, number, number, number ] - | Float32Array; + | IndexedCollection; // prettier-ignore declare type ReadonlyMat2d = @@ -53,7 +58,7 @@ declare type ReadonlyMat2d = number, number, number, number ] - | Float32Array; + | IndexedCollection; // prettier-ignore declare type ReadonlyMat3 = @@ -62,7 +67,7 @@ declare type ReadonlyMat3 = number, number, number, number, number, number ] - | Float32Array; + | IndexedCollection; // prettier-ignore declare type ReadonlyMat4 = @@ -72,18 +77,18 @@ declare type ReadonlyMat4 = number, number, number, number, number, number, number, number ] - | Float32Array; + | IndexedCollection; declare type ReadonlyQuat = | readonly [number, number, number, number] - | Float32Array; + | IndexedCollection; declare type ReadonlyQuat2 = | readonly [number, number, number, number, number, number, number, number] - | Float32Array; + | IndexedCollection; -declare type ReadonlyVec2 = readonly [number, number] | Float32Array; -declare type ReadonlyVec3 = readonly [number, number, number] | Float32Array; +declare type ReadonlyVec2 = readonly [number, number] | IndexedCollection; +declare type ReadonlyVec3 = readonly [number, number, number] | IndexedCollection; declare type ReadonlyVec4 = | readonly [number, number, number, number] - | Float32Array; + | IndexedCollection; From ed6b600f526a8a8937c4c08a2f0f3add9e9f719a Mon Sep 17 00:00:00 2001 From: Andriy Kashcha Date: Thu, 16 Apr 2020 00:05:56 -0700 Subject: [PATCH 2/2] added iterable interface So that it works with type definitions of `uniformMatrixXXX` --- src/types.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.d.ts b/src/types.d.ts index f47b4249..58237b88 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -1,4 +1,4 @@ -interface IndexedCollection { +interface IndexedCollection extends Iterable { readonly length: number; [index: number]: number; }