Skip to content

lib: type Array.fromAsync mapper inputs by source protocol - #65375

Open
David Kaminski (dvkam) wants to merge 1 commit into
microsoft:mainfrom
dvkam:fix/array-fromasync-mapper-input
Open

David Kaminski (dvkam) wants to merge 1 commit into
microsoft:mainfrom
dvkam:fix/array-fromasync-mapper-input

Conversation

@dvkam

Copy link
Copy Markdown

Fixes #65374

Change

Type the Array.fromAsync mapper input according to the source. Async iterables pass the yielded value through. Sync iterables and array-like sources await it. Both paths await the mapper's result.

Tests

Added cases for promise-valued inputs, dual and optional iteration protocols, mixed source types, and explicit type arguments. Updated the affected baselines. The compiler baseline suite passed in default and concurrent modes on the reviewed patch.

I used AI assistance to prepare this change and personally reviewed the code and the issue report.

Copilot AI balanced review requested due to automatic review settings November 7, 2026 00:41
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 7, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The overload order incorrectly infers an unknown mapper input for synchronous iterables with null async methods when strictNullChecks is disabled, rejecting valid Array.fromAsync calls.

No open issues 🎉

What changed in this PR

Updates TypeScript’s ES2026 library declarations to address #65374 by typing Array.fromAsync mapper inputs according to the source’s iteration protocol.

Changes:

  • Separates async, sync, and mixed-source mapper overloads while preserving awaited mapper results.
  • Adds regression cases for promise-valued inputs, dual and optional protocols, and explicit type arguments.
  • Updates compiler and conformance baselines for the new signatures.
File Description
tsc/​testdata/​tests/​cases/​compiler/​arrayFromAsyncMapperInput.ts Adds mapper-input regression cases.
tsc/​testdata/​baselines/​reference/​conformance/​arrayFromAsyncES2026.types Updates expected overload types.
tsc/​testdata/​baselines/​reference/​conformance/​arrayFromAsyncES2026.symbols Records additional overload declarations.
tsc/​testdata/​baselines/​reference/​compiler/​arrayFromAsyncMapperInput.types Records inferred mapper and result types.
tsc/​testdata/​baselines/​reference/​compiler/​arrayFromAsyncMapperInput.symbols Records regression-test symbol bindings.
tsc/​testdata/​baselines/​reference/​compiler/​arrayFromAsyncMapperInput.errors.txt Records expected invalid-mapper diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​arrayFromAsync.types Refreshes existing tests’ overload types.
tsc/​testdata/​baselines/​reference/​compiler/​arrayFromAsync.symbols Refreshes existing tests’ overload symbols.
tsc/​internal/​bundled/​libs/​lib.es2026.array.d.ts Defines protocol-specific mapper overloads.

Review effort: Balanced

@dvkam

Copy link
Copy Markdown
Author

I reproduced the finding locally with strictNullChecks disabled and am looking into it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Array.fromAsync mapper types unwrap promises yielded by async iterables

2 participants