Skip to content

Commit c1b1d40

Browse files
author
Armando Aguirre Sepulveda
committed
Handle truncation in createTypeNodesFromResolvedType
1 parent 44568f7 commit c1b1d40

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/compiler/checker.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
addRange,
77
addRelatedInfo,
88
addSyntheticLeadingComment,
9+
addSyntheticTrailingComment,
910
AliasDeclarationNode,
1011
AllAccessorDeclarations,
1112
AmbientModuleDeclaration,
@@ -7054,6 +7055,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
70547055

70557056
function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] | undefined {
70567057
if (checkTruncationLength(context)) {
7058+
if (context.flags & NodeBuilderFlags.NoTruncation) {
7059+
return [];
7060+
}
7061+
70577062
return [factory.createPropertySignature(/*modifiers*/ undefined, "...", /*questionToken*/ undefined, /*type*/ undefined)];
70587063
}
70597064
const typeElements: TypeElement[] = [];
@@ -7085,7 +7090,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
70857090
}
70867091
}
70877092
if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) {
7088-
typeElements.push(factory.createPropertySignature(/*modifiers*/ undefined, `... ${properties.length - i} more ...`, /*questionToken*/ undefined, /*type*/ undefined));
7093+
if (context.flags & NodeBuilderFlags.NoTruncation) {
7094+
const typeElement = typeElements.pop()!;
7095+
typeElements.push(addSyntheticTrailingComment(typeElement, SyntaxKind.MultiLineCommentTrivia, `... ${properties.length - i} more ...`));
7096+
}
7097+
else {
7098+
typeElements.push(factory.createPropertySignature(/*modifiers*/ undefined, `... ${properties.length - i} more ...`, /*questionToken*/ undefined, /*type*/ undefined));
7099+
}
70897100
addPropertyToElementList(properties[properties.length - 1], context, typeElements);
70907101
break;
70917102
}

tests/baselines/reference/hugeDeclarationOutputGetsTruncatedWithError.types

Lines changed: 8 additions & 9 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)