Skip to content

Commit 1d08203

Browse files
committed
Exclude mapped types with optionality modifiers and 'as' clauses
1 parent 3f63804 commit 1d08203

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12219,8 +12219,11 @@ namespace ts {
1221912219
}
1222012220

1222112221
function isMappedTypeGenericIndexedAccess(type: Type) {
12222-
return type.flags & TypeFlags.IndexedAccess && getObjectFlags((type as IndexedAccessType).objectType) & ObjectFlags.Mapped &&
12223-
!isGenericMappedType((type as IndexedAccessType).objectType) && isGenericIndexType((type as IndexedAccessType).indexType);
12222+
let objectType;
12223+
return !!(type.flags & TypeFlags.IndexedAccess && getObjectFlags(objectType = (type as IndexedAccessType).objectType) & ObjectFlags.Mapped &&
12224+
!isGenericMappedType(objectType) && isGenericIndexType((type as IndexedAccessType).indexType) &&
12225+
!(getMappedTypeModifiers(objectType as MappedType) & (MappedTypeModifiers.IncludeOptional | MappedTypeModifiers.ExcludeOptional)) &&
12226+
!(getNameTypeFromMappedType(objectType as MappedType)));
1222412227
}
1222512228

1222612229
/**

0 commit comments

Comments
 (0)