Conversation
…jectType is mapped by an indexed type itself
|
@ahejlsberg can you take a look at this PR? |
|
@gcnew Thanks for your contribution! You are definitely right about the missing Regarding the other change, the correct fix is to add a check in I'm going to put up a new PR with these changes, but I will keep the tests you wrote. Thanks again! |
|
Funny enough, I tried to fix Now, I'm looking at another issue. Mapped types buried inside an intersection are eagerly resolved, leading to incorrect behaviour (see #17456 and gcnew@73c78e6). The problem is that if the indexing operation is postponed (as in my experiment), the index type is not properly checked. |
|
Closing as the bugs have already been addressed by #17455. |
Fixes #17238
This fix changes the rule from #12351 to:
{ [P in K]: T}[X]is equivalent to an instantiation ofTwhereXis substituted for every occurrence ofP, unlessKis an indexing operation itself. For example,{ [P in K]: Box<T[P]> }[X]is equivalent toBox<T[X]>, however{ [P in T[X]]: Box<T[P]> }[X]is not.This PR also fixes checking of operations done on the object of type indexing, e.g. the following is now correctly identified as error:
Examples: