From 9a5d50562106628e88f7ea846203fcfc0cbfaf0a Mon Sep 17 00:00:00 2001 From: tommy-mitchell Date: Tue, 13 Sep 2022 13:25:20 -0500 Subject: [PATCH] Merge #154 --- .../lib/assertions/handlers/informational.ts | 15 +++++++++++++-- .../informational/print-type/index.d.ts | 18 +++++++++++++++++- .../informational/print-type/index.test-d.ts | 3 ++- source/test/informational.ts | 1 + 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/source/lib/assertions/handlers/informational.ts b/source/lib/assertions/handlers/informational.ts index c0172a8e..a7f08f3e 100644 --- a/source/lib/assertions/handlers/informational.ts +++ b/source/lib/assertions/handlers/informational.ts @@ -1,7 +1,17 @@ -import {CallExpression, TypeChecker} from '@tsd/typescript'; +import {CallExpression, TypeChecker, TypeFormatFlags} from '@tsd/typescript'; import {Diagnostic} from '../../interfaces'; import {makeDiagnostic, tsutils} from '../../utils'; +/** + * Default formatting flags set by TS plus the {@link TypeFormatFlags.NoTruncation NoTruncation} flag. + * + * @see {@link https://github.dev/microsoft/TypeScript/blob/b975dfa1027d1f3073fa7cbe6f7045bf4c882785/src/compiler/checker.ts#L4717 TypeChecker.typeToString} + */ +const typeToStringFormatFlags = + TypeFormatFlags.AllowUniqueESSymbolType | + TypeFormatFlags.UseAliasDefinedOutsideCurrentScope | + TypeFormatFlags.NoTruncation; + /** * Prints the type of the argument of the assertion as a warning. * @@ -19,8 +29,9 @@ export const printTypeWarning = (checker: TypeChecker, nodes: Set { [8, 0, 'warning', 'Type for expression `null as never` is: `never`'], [9, 0, 'warning', 'Type for expression `null as unknown` is: `unknown`'], [10, 0, 'warning', 'Type for expression `\'foo\'` is: `"foo"`'], + [11, 0, 'warning', 'Type for expression `bigType` is: `{ prop1: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop2: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop3: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop4: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop5: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop6: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop7: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop8: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; prop9: SuperTypeWithAnExessiveLongNameThatTakesUpTooMuchSpace; }`'], ]); });