Skip to content

Conversation

ahejlsberg
Copy link
Member

Fixes #1739.

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 bug where insufficient type overlap diagnostics were being incorrectly suppressed during type assertions. The changes ensure that TypeScript's warning about potentially mistaken type conversions (error TS2352) are properly reported alongside property mismatch errors.

Key changes include:

  • Modified the error suppression logic to check for conversion contexts in addition to interface implementation contexts
  • Updated the assertion check logic to properly handle node flags and error reporting location

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

File Description
internal/checker/relater.go Updated error suppression logic to include conversion diagnostics and renamed helper function
internal/checker/checker.go Fixed assertion checking to handle reparsed nodes and removed unrelated case from switch statement
Test baseline files Updated expected error outputs to show TS2352 conversion errors instead of suppressed property errors

c.checkJsxElementDeferred(node)
case ast.KindTypeAssertionExpression, ast.KindAsExpression, ast.KindParenthesizedExpression:
case ast.KindTypeAssertionExpression, ast.KindAsExpression:
c.checkAssertionDeferred(node)
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of ast.KindParenthesizedExpression from this case statement appears unrelated to the main PR purpose of fixing insufficient type overlap diagnostics. This change should be explained or moved to a separate commit to maintain clear separation of concerns.

Suggested change
c.checkAssertionDeferred(node)
c.checkAssertionDeferred(node)
case ast.KindParenthesizedExpression:
c.checkExpression(node.AsParenthesizedExpression().Expression)

Copilot uses AI. Check for mistakes.

@ahejlsberg ahejlsberg added this pull request to the merge queue Sep 23, 2025
Merged via the queue into main with commit 865ec14 Sep 23, 2025
22 checks passed
@ahejlsberg ahejlsberg deleted the fix-1739 branch September 23, 2025 15:42
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.

Different error message when asserting between unrelated types
2 participants