Skip to content

Don't use noErrorTruncation when printing types with maximumLength set #62091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

fixes #62032

cc @gabritto

@Copilot Copilot AI review requested due to automatic review settings July 19, 2025 17:46
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jul 19, 2025
@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug labels Jul 19, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where TypeScript was not properly respecting the maximumLength parameter when printing types, due to the noErrorTruncation compiler option taking precedence. The fix ensures that when a maximumLength is explicitly set, truncation can still occur even if noErrorTruncation is enabled.

  • Modified the logic in typeToTypeNode to only apply noErrorTruncation when no maximumLength is specified
  • Added a test case to verify the fix works correctly with long type definitions

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
src/compiler/checker.ts Updated truncation logic to respect maximumLength parameter over noErrorTruncation setting
tests/cases/fourslash/quickinfoVerbosityNoErrorTruncation1.ts Added test case with long type definition to verify truncation behavior

@@ -6156,7 +6156,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
verbosityLevel?: number,
out?: WriterContextOut,
): string {
const noTruncation = compilerOptions.noErrorTruncation ||
const noTruncation = !maximumLength && compilerOptions.noErrorTruncation ||
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively, compilerOptions.noErrorTruncation could increase the maximumLength to its usual limit - but I think this small solution is a better way out of this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this, the another user who reported the problem here gets:
image

and they agree it's an improvement but they still can't expand this type in VS Code - when they can expand other types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Incorrect any displayed in type with noErrorTruncation: true
2 participants