Fixed an issue with optionality not being stripped from generic mapped types on indexed access - #59921
Conversation
…d types on indexed access
| const mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); | ||
| const templateMapper = combineTypeMappers(objectType.mapper, mapper); | ||
| const instantiatedTemplateType = instantiateType(getTemplateTypeFromMappedType(objectType.target as MappedType || objectType), templateMapper); | ||
| const isOptional = getMappedTypeOptionality(objectType) > 0 || (isGenericType(objectType) ? |
There was a problem hiding this comment.
In the given repro the immediate modifiers type has -? for which getMappedTypeOptionality returns -1. So the first condition was not satisfied and the compiler proceeded to compute getCombinedMappedTypeOptionality. This time it was called with the modifiers type and not the original object type. Since that was a mapped type too it got its modifiers type etc.
Essentially this was skipping the outermost mapped type modifiers in this scenario - the ones that were supposed strip the optionality.
|
With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies). Next steps for PRs:
|
fixes #59902