Repository navigation
lib: type Array.fromAsync mapper inputs by source protocol - #65375
Open
David Kaminski (dvkam) wants to merge 1 commit into
Open
David Kaminski (dvkam) wants to merge 1 commit into
David Kaminski (dvkam) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🔵 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
Author
|
I reproduced the finding locally with |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #65374
Change
Type the
Array.fromAsyncmapper 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.