Skip to content

Commit bdf7a35

Browse files
author
Armando Aguirre Sepulveda
committed
Handle truncation in createTypeNodesFromResolvedType
1 parent a480748 commit bdf7a35

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,
@@ -7026,6 +7027,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
70267027

70277028
function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] | undefined {
70287029
if (checkTruncationLength(context)) {
7030+
if (context.flags & NodeBuilderFlags.NoTruncation) {
7031+
return [];
7032+
}
7033+
70297034
return [factory.createPropertySignature(/*modifiers*/ undefined, "...", /*questionToken*/ undefined, /*type*/ undefined)];
70307035
}
70317036
const typeElements: TypeElement[] = [];
@@ -7057,7 +7062,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
70577062
}
70587063
}
70597064
if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) {
7060-
typeElements.push(factory.createPropertySignature(/*modifiers*/ undefined, `... ${properties.length - i} more ...`, /*questionToken*/ undefined, /*type*/ undefined));
7065+
if (context.flags & NodeBuilderFlags.NoTruncation) {
7066+
const typeElement = typeElements.pop()!;
7067+
typeElements.push(addSyntheticTrailingComment(typeElement, SyntaxKind.MultiLineCommentTrivia, `... ${properties.length - i} more ...`));
7068+
}
7069+
else {
7070+
typeElements.push(factory.createPropertySignature(/*modifiers*/ undefined, `... ${properties.length - i} more ...`, /*questionToken*/ undefined, /*type*/ undefined));
7071+
}
70617072
addPropertyToElementList(properties[properties.length - 1], context, typeElements);
70627073
break;
70637074
}

tests/baselines/reference/hugeDeclarationOutputGetsTruncatedWithError.types

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

0 commit comments

Comments
 (0)