Skip to content

Conversation

ahejlsberg
Copy link
Member

Fixes #1563.

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 issue #1563 by improving TypeScript's subtype reduction algorithm to prefer implicit empty object types ({}) over explicitly declared empty object types in union types. The change addresses a type checking discrepancy where v || {} was incorrectly being assigned the explicitly declared empty object type instead of the implicit one.

Key changes:

  • Added logic in the subtype reduction algorithm to prioritize implicit empty object types
  • Added a comprehensive test case to verify the fix

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/implicitEmptyObjectType.ts New test case demonstrating the issue with unknown || {} type assignment
testdata/baselines/reference/compiler/implicitEmptyObjectType.types Expected type output showing v || {} resolves to {} type
testdata/baselines/reference/compiler/implicitEmptyObjectType.symbols Expected symbol resolution baseline for the test
testdata/baselines/reference/compiler/implicitEmptyObjectType.errors.txt Expected error output showing type assignment error
internal/checker/checker.go Core fix in subtype reduction to prefer implicit empty object types
Comments suppressed due to low confidence (1)

@ahejlsberg ahejlsberg added this pull request to the merge queue Aug 19, 2025
Merged via the queue into main with commit 5d54ac8 Aug 19, 2025
22 checks passed
@ahejlsberg ahejlsberg deleted the fix-1563 branch August 19, 2025 18:39
zshannon pushed a commit to zshannon/typescript-go that referenced this pull request Oct 6, 2025
zshannon pushed a commit to zshannon/typescript-go that referenced this pull request Oct 6, 2025
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.

Behavior difference using || {} with unknown
2 participants