Skip to content

TypedArrays: type thisArg correctly and other issues #18425

Closed
@NaridaL

Description

@NaridaL

For example, UInt8Array.find

// currently:
find(
    predicate: (value: number, index: number, obj: Array<number>) => boolean, 
    thisArg?: any): number | undefined;
// better:
find<Z = undefined>(
    predicate: (this: Z, value: number, index: number, obj: this) => boolean,
    thisArg?: Z): number | undefined;

All the variants have the same issues. It seems like it would be a good idea to refactor them to:

interface TypedArray<ArrType> {
// find etc
}
interface UInt8Array extends TypedArray<UInt8Array> {}
interface UInt16Array extends TypedArray<UInt16Array> {}
// etc

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions