@@ -427,10 +427,10 @@ export function defineStruct<const Props extends PropertyDescriptorMap>(
427427 * @param arrayOptions
428428 * @returns A new class, inheriting from `Struct` whose elements are statically typed structs
429429 */
430- export function defineArray < Ctor extends StructConstructor < object > > (
430+ export function defineArray < Item extends object > (
431431 arrayOptions : {
432432 /** Constructor for an object view of each item */
433- struct : Ctor
433+ struct : StructConstructor < Item >
434434 /** Number of bytes between the start of consecutive items */
435435 byteStride : number
436436 /** Total number of items in the array (not bytes). If omitted, the array length will depend on the size of its underlying buffer */
@@ -439,8 +439,8 @@ export function defineArray<Ctor extends StructConstructor<object>>(
439439) : StructConstructor <
440440 {
441441 readonly length : number
442- element ( i : number ) : InstanceType < Ctor >
443- } & Iterable < InstanceType < Ctor > >
442+ element ( i : number ) : Item
443+ } & Iterable < Item >
444444> {
445445 const { struct, byteStride, length } = arrayOptions
446446
@@ -464,7 +464,7 @@ export function defineArray<Ctor extends StructConstructor<object>>(
464464 * @param index
465465 * @returns a new struct instance viewing the item at the given index
466466 */
467- item ( index : number ) {
467+ item ( index : number ) : Item {
468468 const ctor = this . #struct
469469 return new ctor (
470470 structBytes (
@@ -487,6 +487,5 @@ export function defineArray<Ctor extends StructConstructor<object>>(
487487 }
488488 }
489489 }
490- // deno-lint-ignore no-explicit-any
491- return StructArray as any
490+ return StructArray
492491}
0 commit comments