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.
This commit is contained in:
Nathan Shively-Sanders 2018-01-03 15:49:09 -08:00
parent a43adad080
commit 8616170060

View File

@ -2860,8 +2860,11 @@ namespace ts {
for (const signature of resolvedType.constructSignatures) {
typeElements.push(<ConstructSignatureDeclaration>signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructSignature, context));
}
if (resolvedType.stringIndexInfo) {
typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, IndexKind.String, context));
if (resolvedType.stringIndexInfo && !(resolvedType.objectFlags & ObjectFlags.Deferred)) {
const indexInfo = resolvedType.objectFlags & ObjectFlags.Deferred ?
createIndexInfo(emptyObjectType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration) :
resolvedType.stringIndexInfo;
typeElements.push(indexInfoToIndexSignatureDeclarationHelper(indexInfo, IndexKind.String, context));
}
if (resolvedType.numberIndexInfo) {
typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, IndexKind.Number, context));