Repository navigation
fix: map constructor param type - #64901
Open
Dave van Soest (tbknl) wants to merge 9 commits into
Open
Dave van Soest (tbknl) wants to merge 9 commits into
Dave van Soest (tbknl) wants to merge 9 commits into
Conversation
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The overload ordering breaks empty-map insertion when only the collection library is included.
No open issues 🎉
What changed in this PR
Improves Map constructor inference for heterogeneous keys and values, addressing #37527, #33611, and #39133.
Changes:
- Adds an overload that derives key and value types from entry arrays.
- Adds regression cases and updates inferred-type and diagnostic baselines.
| File | Description |
|---|---|
| tsc/testdata/tests/cases/conformance/es6/mapConstruction/new-Map1.ts | Adds heterogeneous-entry tests. |
| tsc/testdata/baselines/reference/conformance/new-Map1.types | Records inferred map types. |
| tsc/testdata/baselines/reference/conformance/new-Map1.symbols | Records test symbols. |
| tsc/testdata/baselines/reference/conformance/new-Map1.js | Records emitted JavaScript. |
| tsc/testdata/baselines/reference/conformance/iterableArrayPattern28.types | Updates union value types. |
| tsc/testdata/baselines/reference/conformance/iterableArrayPattern28.errors.txt | Updates argument mismatch diagnostics. |
| tsc/testdata/baselines/reference/conformance/for-of39.types | Updates loop value inference. |
| tsc/testdata/baselines/reference/conformance/for-of39.errors.txt | Removes obsolete constructor errors. |
| tsc/testdata/baselines/reference/compiler/newMap.errors.txt | Updates type-argument diagnostics. |
| tsc/internal/bundled/libs/lib.es2015.collection.d.ts | Adds entry-array inference overload. |
Review effort: Balanced
Author
Specific library-only test coverage (e.g. to test only with collection lib without the iterable lib) does not appear to exist in this repo. |
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 #37527
Fixes #33611
Fixes #39133
Additional notes
MapConstructorinterface in the iterable lib is updated to align this behavior. Note that prior to this PR, the type ofm1in this example was inferred differently for both libs.