Skip to content

Commit 73d96e1

Browse files
committed
fix index type constraints on mapped types with name types
1 parent 81185ac commit 73d96e1

File tree

5 files changed

+2166
-1
lines changed

5 files changed

+2166
-1
lines changed

src/compiler/checker.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15299,7 +15299,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1529915299
const constraint = getResolvedBaseConstraint(type as InstantiableType | UnionOrIntersectionType);
1530015300
return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined;
1530115301
}
15302-
return type.flags & TypeFlags.Index ? stringNumberSymbolType : undefined;
15302+
if (type.flags & TypeFlags.Index) {
15303+
if (isGenericMappedType((type as IndexType).type)) {
15304+
const nameType = getNameTypeFromMappedType((type as IndexType).type as MappedType);
15305+
if (nameType) {
15306+
return getBaseConstraintOfType(nameType);
15307+
}
15308+
}
15309+
return stringNumberSymbolType;
15310+
}
15311+
return undefined;
1530315312
}
1530415313

1530515314
/**

0 commit comments

Comments
 (0)