Skip to content

Resolve apparent mapped types recursively #57091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14558,9 +14558,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
constraint = getConstraintOfTypeParameter(typeVariable);
}
else {
const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
if (modifiersConstraint) {
constraint = getApparentType(modifiersConstraint);
const modifiersType = getModifiersTypeFromMappedType(type);
if (modifiersType) {
constraint = getApparentType(getConstraintOfType(modifiersType) || modifiersType);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not particularly fond of this - maybe there is a better way of doing this. This mainly tries to get the apparent type of the modifiers type when the modifiers type is a mapped type itself (like in Mapped<Mapped2<Foo>>). Mapped types don't return anything from getConstraintOfType.

}
}
if (constraint && everyType(constraint, isArrayOrTupleType)) {
Expand Down