Skip to content

Improve @overload error message to include host function name#3315

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/improve-overload-error-message
Draft

Improve @overload error message to include host function name#3315
Copilot wants to merge 2 commits intomainfrom
copilot/improve-overload-error-message

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

TS7012 for JSDoc @overload tags didn't include the host function name, making it less actionable than the equivalent TypeScript overload error.

Before: This overload implicitly returns the type 'any' because it lacks a return type annotation.
After: This overload of 'id' lacks a return-type annotation and implicitly has an 'any' return type.

Changes

  • extraDiagnosticMessages.json: Overrides TS submodule code 7012 with a two-parameter format "This overload of '{0}' lacks a return-type annotation and implicitly has an '{1}' return type." — the extra messages file takes precedence over the submodule during generation.
  • diagnostics_generated.go: Regenerated; old This_overload_implicitly_returns_the_type_0_... replaced by This_overload_of_0_lacks_a_return_type_annotation_and_implicitly_has_an_1_return_type.
  • checker.go: At the NodeFlagsReparsed branch (reparsed @overload synthetic function declarations), passes DeclarationNameToString(GetNameOfDeclaration(declaration)) as {0} and the widened type as {1}. The name is always non-nil at this point since anonymous declarations are handled by the earlier Name() == nil guard.
  • Baselines: Updated jsFileMethodOverloads3 and templateInsideCallback baselines; added jsFileMethodOverloads3.errors.txt.diff to record the intentional divergence from the upstream TS submodule baseline.
/**
 * @overload
 * @param {number} x
 */
/**
 * @overload
 * @param {string} x
 */
function id(x) { return x; }
// error TS7012: This overload of 'id' lacks a return-type annotation and implicitly has an 'any' return type.

Copilot AI changed the title [WIP] Improve @overload error message to mention name of host function Improve @overload error message to include host function name Apr 1, 2026
Copilot AI requested a review from RyanCavanaugh April 1, 2026 21:18
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.

Improve @overload error message to mention name of host function

2 participants