Fix off-by-one truncation in union type display#3658
Merged
gabritto merged 2 commits intomicrosoft:mainfrom Apr 29, 2026
Merged
Fix off-by-one truncation in union type display#3658gabritto merged 2 commits intomicrosoft:mainfrom
gabritto merged 2 commits intomicrosoft:mainfrom
Conversation
Andarist
commented
Apr 29, 2026
| @@ -380,11 +380,12 @@ func (b *NodeBuilderImpl) mapToTypeNodes(list []*Type, isBareList bool) *ast.Nod | |||
| result := make([]*ast.Node, 0, len(list)) | |||
|
|
|||
| for i, t := range list { | |||
Contributor
Author
There was a problem hiding this comment.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a behavioral mismatch in tsgo’s type display truncation logic (notably affecting TS7053 diagnostics) by correcting an off-by-one in the “... N more ...” elision calculation and adding a regression test to lock in the expected output.
Changes:
- Fix off-by-one logic in
NodeBuilderImpl.mapToTypeNodeswhen emitting truncated type lists (union/intersection/type-arg lists). - Add a new compiler test case covering union element error truncation.
- Update affected reference baselines (compiler, fourslash quick info, and a submodule baseline) to reflect the corrected display output.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
internal/checker/nodebuilderimpl.go |
Fixes the truncation/elision count calculation and the truncation trigger condition for type list rendering. |
testdata/tests/cases/compiler/unionElementErrorTruncation.ts |
Adds a regression test that reproduces the union truncation count mismatch seen in #3647. |
testdata/baselines/reference/compiler/unionElementErrorTruncation.errors.txt |
New expected diagnostic output for the new regression test. |
testdata/baselines/reference/compiler/unionElementErrorTruncation.js |
New expected emit baseline for the new regression test (includes .d.ts section due to @declaration: true). |
testdata/baselines/reference/compiler/unionElementErrorTruncation.symbols |
New expected symbols baseline for the new regression test. |
testdata/baselines/reference/compiler/unionElementErrorTruncation.types |
New expected types baseline for the new regression test. |
testdata/baselines/reference/fourslash/quickInfo/quickinfoVerbosityNoErrorTruncation1.baseline |
Updates quickinfo truncation text to reflect corrected “... N more ...” counts. |
testdata/baselines/reference/submodule/compiler/declarationEmitPrivatePromiseLikeInterface.js |
Updates a declaration emit baseline affected by the adjusted truncation behavior. |
testdata/baselines/reference/submodule/compiler/declarationEmitPrivatePromiseLikeInterface.js.diff |
Updates the corresponding .diff baseline for the same truncation-related output change. |
gabritto
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #3647