Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypedArray constructors: missing from mapping iterable #45199

Closed
mfulton26 opened this issue Jul 27, 2021 · 0 comments · Fixed by #60151 · May be fixed by #50450
Closed

TypedArray constructors: missing from mapping iterable #45199

mfulton26 opened this issue Jul 27, 2021 · 0 comments · Fixed by #60151 · May be fixed by #50450
Assignees
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@mfulton26
Copy link
Contributor

lib Update Request

Configuration Check

My compilation target is ESNext and my lib is the default.

Missing / Incorrect Definition

Typed array constructors (Int8Array, Float32Array, BigInt64Array, etc.) are missing an iterable overload that transforms from some non-number/bigint type to the desired number/bigint type.

Sample Code

console.log(
  Int32Array.from(new Set(["1", "2", "3"]), (value) => Number(value) ** 2).join(", ")
);
No overload matches this call.
  Overload 1 of 3, '(arrayLike: Iterable<number>, mapfn?: ((v: number, k: number) => number) | undefined, thisArg?: any): Int32Array', gave the following error.
    Argument of type 'Set<string>' is not assignable to parameter of type 'Iterable<number>'.
      The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
        Type 'IteratorResult<string, any>' is not assignable to type 'IteratorResult<number, any>'.
          Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorResult<number, any>'.
            Type 'IteratorYieldResult<string>' is not assignable to type 'IteratorYieldResult<number>'.
              Type 'string' is not assignable to type 'number'.
  Overload 2 of 3, '(arrayLike: ArrayLike<unknown>, mapfn: (v: unknown, k: number) => number, thisArg?: any): Int32Array', gave the following error.
    Argument of type 'Set<string>' is not assignable to parameter of type 'ArrayLike<unknown>'.
      Property 'length' is missing in type 'Set<string>' but required in type 'ArrayLike<unknown>'.

Documentation Link

TypedArray.from() - JavaScript | MDN

@andrewbranch andrewbranch added this to the TypeScript 4.5.0 milestone Aug 4, 2021
@andrewbranch andrewbranch added the Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript label Aug 4, 2021
@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Dec 15, 2021
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fix Available A PR has been opened for this issue Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
5 participants