Skip to content

Conversation

ahejlsberg
Copy link
Member

Fixes #1774.

@Copilot Copilot AI review requested due to automatic review settings October 1, 2025 21:32
Copy link
Contributor

@Copilot Copilot AI left a comment

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 a TypeScript assertion function bug by allowing expando property functions with return type annotations to be used as assertions. The fix addresses issue #1774 by updating the type checker to recognize when a function assigned to an object property has an explicit return type annotation (like assertion signatures).

  • Adds logic to recognize expando property functions with return type annotations as valid for assertions
  • Updates the explicit type annotation detection to include this case
  • Removes a duplicate error diagnostic call

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
testdata/tests/cases/compiler/expandoFunctionAsAssertion.ts Test case demonstrating expando function with assertion signature
testdata/baselines/reference/compiler/expandoFunctionAsAssertion.types Expected type output baseline for the new test
testdata/baselines/reference/compiler/expandoFunctionAsAssertion.symbols Expected symbol output baseline for the new test
internal/checker/flow.go Adds detection logic for expando property functions with return type annotations
internal/checker/checker.go Removes duplicate error diagnostic call

@ahejlsberg ahejlsberg added this pull request to the merge queue Oct 1, 2025
Merged via the queue into main with commit b8983f4 Oct 2, 2025
22 checks passed
@ahejlsberg ahejlsberg deleted the fix-1774 branch October 2, 2025 00:08
@wincent
Copy link

wincent commented Oct 2, 2025

Thanks for the quick fix! 🙇🏻

wincent added a commit to wincent/wincent that referenced this pull request Oct 2, 2025
To obtain this fix:

- microsoft/typescript-go#1787

With this, we have a clean build with no errors and can switch over to
the preview.
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.

tsgo produces TS2775 for function with assertion function assigned to a property but tsc does not
3 participants