Skip to content

Select "types returned by" vs "types of" from the merged dotted name in relation errors - #4772

Draft
RyanCavanaugh with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-ts2719-ts2322-false-positive-again
Draft

Select "types returned by" vs "types of" from the merged dotted name in relation errors#4772
RyanCavanaugh with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-ts2719-ts2322-false-positive-again

Conversation

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

The repro in the linked issue produces an identical TS2719 chain under tsc and tsgo except for one line, where tsgo picks the wrong condensed message:

tsc : The types returned by 'defaultColumn.Cell(...)' are incompatible between these types.
tsgo: The types of 'defaultColumn.Cell(...)' are incompatible between these types.

(Note: the underlying TS2719 is reported by tsc 5.9 and 6.0.3 on this reduction too, and the original material-react-table sample from the issue body is now clean under both compilers.)

Root cause

Relater.reportError condenses a chain of Types_of_property_0_are_incompatible and signature-return-type messages into a single dotted-name message, but chose the final message from the incoming message rather than the merged path:

if message == diagnostics.Types_of_property_0_are_incompatible {
    message = diagnostics.The_types_of_0_are_incompatible_between_these_types
}

Upstream reportIncompatibleStack keys off the last character of the assembled path (path[path.length - 1] === ")"). The tsgo version was wrong in both directions: foo + bar(...) collapsed to "The types of", while bar() + .baz retained "The types returned by".

Changes

  • internal/checker/relater.go: pick the message from the merged dotted name — The_types_returned_by_0_... when it ends in ), otherwise The_types_of_0_....
  • testdata/tests/cases/compiler/nestedReturnTypeIncompatibleMessage.ts: new test covering foo.bar(...), foo.bar.baz(...), foo.bar.baz, and foo.bar().baz.
  • Baselines: complexRecursiveCollections now matches the reference implementation, so its accepted .diff and the corresponding testdata/submoduleAccepted.txt entry are removed.

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix TS2719/TS2322 false positive on generic type Select "types returned by" vs "types of" from the merged dotted name in relation errors Jul 28, 2026
Copilot AI requested a review from RyanCavanaugh July 28, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TS2719/TS2322 false positive on a generic type forwarded through an interface extends boundary (tsc clean, tsgo fails)

2 participants