fix: prevent false assignability for types with methods like Map and Set - #2514
Open
puckey wants to merge 2 commits into
Open
fix: prevent false assignability for types with methods like Map and Set#2514puckey wants to merge 2 commits into
puckey wants to merge 2 commits into
Conversation
puckey
force-pushed
the
fix/conditional-type-assignability
branch
2 times, most recently
from
March 30, 2026 14:28
fe96889 to
cedd993
Compare
arthurfiorette
approved these changes
Mar 30, 2026
arthurfiorette
enabled auto-merge (squash)
March 30, 2026 19:39
auto-merge was automatically disabled
March 31, 2026 07:12
Head branch was pushed to by a user without write access
puckey
force-pushed
the
fix/conditional-type-assignability
branch
from
March 31, 2026 07:12
cedd993 to
50d6a06
Compare
Contributor
Author
|
Fixed the formatting in the latest push. |
Interfaces like Map and Set have method signatures that aren't included in ObjectType properties, causing isAssignableTo to consider any object with a `size` property assignable to Map. This produced wrong conditional type branches (e.g. Immutable<T> with `T extends Map<infer K, infer V>`). - Track method names on ObjectType, collected in InterfaceAndClassNodeParser - Check method names in isAssignableTo to reject false structural matches
puckey
force-pushed
the
fix/conditional-type-assignability
branch
from
March 31, 2026 07:17
50d6a06 to
cbfa79c
Compare
Contributor
Author
|
Rebased on next and ran tests. |
domoritz
enabled auto-merge (squash)
April 7, 2026 15:10
arthurfiorette
approved these changes
Jun 18, 2026
Collaborator
|
@puckey CI is failing |
TS6 flags moduleResolution=node (node10) as deprecated (TS5107), which getPreEmitDiagnostics surfaces and createProgram throws on, failing CI.
auto-merge was automatically disabled
June 19, 2026 07:24
Head branch was pushed to by a user without write access
Contributor
Author
|
Thanks for the heads up! The failure wasn't the assignability logic — it was the two new test fixtures' |
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.
Summary
MapandSethave method signatures that aren't included inObjectTypeproperties, causingisAssignableToto consider any object with asizeproperty assignable toMapImmutable<Bar>withT extends Map<infer K, infer V>incorrectly matching whenBarhas asizeproperty)ObjectType, collected inInterfaceAndClassNodeParserisAssignableToto reject false structural matchesTest plan
type-awaited-return-type-break—Immutable<T>with Map/Set branches correctly resolves all propertiestype-self-referencing-method— interfaces withthis-returning methods don't cause stack overflow