Fix missing TS2385 error for constructor overload visibility disagreement#2706
Merged
andrewbranch merged 3 commits intomainfrom Feb 7, 2026
Merged
Fix missing TS2385 error for constructor overload visibility disagreement#2706andrewbranch merged 3 commits intomainfrom
andrewbranch merged 3 commits intomainfrom
Conversation
…ment Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix missing error for overload signature visibility disagreement
Fix missing TS2385 error for constructor overload visibility disagreement
Feb 6, 2026
Member
|
@copilot delete the new test and baselines because it looks like an existing submodule test was fixed. |
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
Contributor
Author
andrewbranch
approved these changes
Feb 6, 2026
jakebailey
approved these changes
Feb 6, 2026
| c.error(ast.GetNameOfDeclaration(overload), diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient) | ||
| case deviation&(ast.ModifierFlagsPrivate|ast.ModifierFlagsProtected) != 0: | ||
| c.error(ast.GetNameOfDeclaration(overload), diagnostics.Overload_signatures_must_all_be_public_private_or_protected) | ||
| c.error(core.OrElse(ast.GetNameOfDeclaration(overload), overload), diagnostics.Overload_signatures_must_all_be_public_private_or_protected) |
Member
There was a problem hiding this comment.
Old code was
error(getNameOfDeclaration(o) || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);sneaky
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a TypeScript conformance gap where tsgo failed to emit TS2385 for constructor overloads with mismatched visibility by ensuring diagnostics attach to a valid node for constructors.
Changes:
- Fix diagnostic location for TS2385 visibility mismatch by falling back from missing constructor name nodes to the overload node.
- Update the conformance baseline to reflect the now-reported TS2385 errors.
- Remove the no-longer-needed baseline
.diffartifact.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/checker/checker.go | Ensures TS2385 is reported for constructor overload visibility mismatches by using a valid fallback node for errors. |
| testdata/baselines/reference/submodule/conformance/classConstructorOverloadsAccessibility.errors.txt | Updates expected error output to include the newly surfaced TS2385 diagnostics and spans. |
| testdata/baselines/reference/submodule/conformance/classConstructorOverloadsAccessibility.errors.txt.diff | Removes an outdated/now-unnecessary diff artifact after updating the baseline. |
Comments suppressed due to low confidence (1)
internal/checker/checker.go:1
- Only the TS2385 (visibility) branch uses a fallback node when
GetNameOfDeclaration(overload)is nil (constructors). The other diagnostic branches still passGetNameOfDeclaration(overload)directly, which can reintroduce the same ‘missing diagnostic location’ issue for constructors if those deviation cases ever apply. Consider computing a singleerrorNode := core.OrElse(ast.GetNameOfDeclaration(overload), overload)once and using it for allc.error(...)calls in this switch.
Copilot AI
added a commit
that referenced
this pull request
Feb 25, 2026
…ment (#2706) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
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.
tsgo was not reporting TS2385 when constructor overload signatures had mismatched visibility modifiers (public/private/protected), while TypeScript correctly errors:
Changes
internal/checker/checker.go: Addedcore.OrElsefallback incheckFlagAgreementBetweenOverloadswhen reporting visibility disagreement errors.GetNameOfDeclarationreturnsnilfor constructors (they have no name field), causing diagnostics to be created with no location and silently ignored. Now falls back to the overload node itself, matching TypeScript'sgetNameOfDeclaration(o) || opattern.Test coverage: The fix corrects the existing submodule test
classConstructorOverloadsAccessibility.tsfrom the TypeScript test suite, which now properly reports 3 errors instead of 0.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.