Skip to content

Commit 8616170

Browse files
committed
Fix printing of deferred mapped types
A deferred mapped type with a source that has an index signature now prints {} as the type of the index signature. This avoids an infinite recursion.
1 parent a43adad commit 8616170

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/compiler/checker.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,8 +2860,11 @@ namespace ts {
28602860
for (const signature of resolvedType.constructSignatures) {
28612861
typeElements.push(<ConstructSignatureDeclaration>signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructSignature, context));
28622862
}
2863-
if (resolvedType.stringIndexInfo) {
2864-
typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, IndexKind.String, context));
2863+
if (resolvedType.stringIndexInfo && !(resolvedType.objectFlags & ObjectFlags.Deferred)) {
2864+
const indexInfo = resolvedType.objectFlags & ObjectFlags.Deferred ?
2865+
createIndexInfo(emptyObjectType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration) :
2866+
resolvedType.stringIndexInfo;
2867+
typeElements.push(indexInfoToIndexSignatureDeclarationHelper(indexInfo, IndexKind.String, context));
28652868
}
28662869
if (resolvedType.numberIndexInfo) {
28672870
typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, IndexKind.Number, context));

0 commit comments

Comments
 (0)