Skip to content

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

Merged
Gabriela Araujo Britto (gabritto) merged 2 commits into
microsoft:mainfrom
Andarist:dont-use-noerror-truncation-when-max-length-set
Jul 22, 2025
Merged

Don't use noErrorTruncation when printing types with maximumLength set#62091
Gabriela Araujo Britto (gabritto) merged 2 commits into
microsoft:mainfrom
Andarist:dont-use-noerror-truncation-when-max-length-set

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

CopilotAI review requested due to automatic review settings July 19, 2025 17:46
@github-project-automationgithub-project-automationBot moved this to Not started in PR BacklogJul 19, 2025
@typescript-botTypeScript Bot (typescript-bot) added For Backlog Bug PRs that fix a backlog bug labels Jul 19, 2025

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

FileDescription
src/compiler/checker.tsUpdated truncation logic to respect maximumLength parameter over noErrorTruncation setting
tests/cases/fourslash/quickinfoVerbosityNoErrorTruncation1.tsAdded test case with long type definition to verify truncation behavior

out?: WriterContextOut,
): string {
const noTruncation = compilerOptions.noErrorTruncation ||
const noTruncation = !maximumLength && compilerOptions.noErrorTruncation ||

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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

@github-project-automationgithub-project-automationBot moved this from Not started to Needs merge in PR BacklogJul 22, 2025
@gabritto
Gabriela Araujo Britto (gabritto) merged commit d5a414c into microsoft:mainJul 22, 2025
32 checks passed
@github-project-automationgithub-project-automationBot moved this from Needs merge to Done in PR BacklogJul 22, 2025
@Andarist
Mateusz Burzyński (Andarist) deleted the dont-use-noerror-truncation-when-max-length-set branch July 23, 2025 08:39
@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Jan 20, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Backlog BugPRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Incorrect any displayed in type with noErrorTruncation: true

7 participants

@Andarist@gabritto@DanielRosenwasser@andrewbranch@jakebailey@typescript-bot