Skip to content

Commit 868b7b9

Browse files
committed
Avoid expensive relationship checking in mapped type member resolution
1 parent b8b5948 commit 868b7b9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/checker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9589,7 +9589,7 @@ namespace ts {
95899589
// When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the
95909590
// type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks
95919591
// mode, if the underlying property is optional we remove 'undefined' from the type.
9592-
prop.type = strictNullChecks && isOptional && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) :
9592+
prop.type = strictNullChecks && isOptional && !maybeTypeOfKind(propType, TypeFlags.Undefined | TypeFlags.Void) ? getOptionalType(propType) :
95939593
strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & SymbolFlags.Optional ? getTypeWithFacts(propType, TypeFacts.NEUndefined) :
95949594
propType;
95959595
if (modifiersProp) {
@@ -13681,7 +13681,7 @@ namespace ts {
1368113681
const templateMapper = combineTypeMappers(mapper, createTypeMapper([getTypeParameterFromMappedType(type)], [key]));
1368213682
const propType = instantiateType(getTemplateTypeFromMappedType(<MappedType>type.target || type), templateMapper);
1368313683
const modifiers = getMappedTypeModifiers(type);
13684-
return strictNullChecks && modifiers & MappedTypeModifiers.IncludeOptional && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) :
13684+
return strictNullChecks && modifiers & MappedTypeModifiers.IncludeOptional && !maybeTypeOfKind(propType, TypeFlags.Undefined | TypeFlags.Void) ? getOptionalType(propType) :
1368513685
strictNullChecks && modifiers & MappedTypeModifiers.ExcludeOptional && isOptional ? getTypeWithFacts(propType, TypeFacts.NEUndefined) :
1368613686
propType;
1368713687
}

0 commit comments

Comments
 (0)