Generic mapped type constrained by a type parameter has different members / index signatures when constraint of that type parameter is a union #27819
Labels
Bug
A bug in TypeScript
Domain: Mapped Types
The issue relates to mapped types
Fixed
A PR has been merged for this issue
TypeScript Version: master (b2bae85)
Search Terms: mapped type parameter member index signature constraint constrained union
Code (with noImplicitAny)
Expected behavior: Consistent behavior between
foo1
andfoo2
and betweenfoo3
andfoo4
.Actual behavior: As marked.
Playground Link: link (with noImplicitAny)
Related Issues: None found.
Looks like the cause is that this line in
resolvedMappedTypeMembers
in the checker is usinggetApparentType
, which changes eitherstring
or"foo"
toString
(which doesn't generate an index signature) but leaves unions alone. What was the thinking here??The text was updated successfully, but these errors were encountered: