Nested mapped types still evaluated eagerly in some cases, causing surprising/incorrect behavior #18089
Labels
Working as Intended
The behavior described is the intended behavior; this is not a bug
TypeScript Version: 2.6.0-dev.20170824 (not in 2.4 or 2.5)
(Moving from a comment to a new issue)
Now that the fix for #15756 is in (#18042), I tried implementing the type function
Transpose
, which reverses a mapping of string literals. Example:Here is a version of
Transpose
that still doesn't work:Expected behavior:
WhoLikes['chocolate']
should be'alice' | 'bob' | 'dave'
.Actual behavior:
WhoLikes['chocolate']
is'alice' | 'bob' | 'carol' | 'dave' | 'eve'
. Something is still doing an eager substitution where I don't expect it.I'm not sure if this is the minimal example of this issue; seems only to show up with a certain amount or level of nesting of mapped type definitions and applications. I think this is still a bug but I'm not sure. Thoughts?
Note that the default-generic workaround does work here:
so I do have a working
Transpose
in 2.6.0-dev.20170824, but I'm not sure if the workaround is necessary.The text was updated successfully, but these errors were encountered: