Add huge maximal length for noTruncation mode (#37461)

This commit is contained in:
Wesley Wigham 2020-03-19 10:45:00 -07:00 committed by GitHub
parent 237ea526f9
commit e2156a1535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -4010,7 +4010,7 @@ namespace ts {
printer.writeNode(EmitHint.Unspecified, typeNode, /*sourceFile*/ sourceFile, writer);
const result = writer.getText();
const maxLength = noTruncation ? undefined : defaultMaximumTruncationLength * 2;
const maxLength = noTruncation ? noTruncationMaximumTruncationLength * 2 : defaultMaximumTruncationLength * 2;
if (maxLength && result && result.length >= maxLength) {
return result.substr(0, maxLength - "...".length) + "...";
}
@ -4083,7 +4083,7 @@ namespace ts {
function checkTruncationLength(context: NodeBuilderContext): boolean {
if (context.truncating) return context.truncating;
return context.truncating = !(context.flags & NodeBuilderFlags.NoTruncation) && context.approximateLength > defaultMaximumTruncationLength;
return context.truncating = context.approximateLength > ((context.flags & NodeBuilderFlags.NoTruncation) ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
}
function typeToTypeNodeHelper(type: Type, context: NodeBuilderContext): TypeNode {

View File

@ -7,6 +7,7 @@ namespace ts {
export const externalHelpersModuleNameText = "tslib";
export const defaultMaximumTruncationLength = 160;
export const noTruncationMaximumTruncationLength = 1_000_000;
export function getDeclarationOfKind<T extends Declaration>(symbol: Symbol, kind: T["kind"]): T | undefined {
const declarations = symbol.declarations;