Skip to content

Conversation

@ahejlsberg
Copy link
Member

This PR reorders the TypeFlags enum such that

  • the object type sorts before actual object types, and
  • union and intersection types sort after all other types.

This fixes #1164 and also ensures that union subtype reduction prefers non-intersections over intersections when types are mutual subtypes.

Fixes #1164.

@ahejlsberg ahejlsberg requested review from DanielRosenwasser, Copilot and jakebailey and removed request for Copilot June 18, 2025 18:30
Copy link
Contributor

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 reorders the TypeFlags enum to improve the sort order of types, placing the object type and nonprimitive flag earlier and shifting union and intersection types later. Key changes include updating the bit-shift values in internal/checker/types.go and corresponding updates to many baseline test outputs that reflect the new ordering.

Reviewed Changes

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

File Description
internal/checker/types.go Reordering of type flag constants to support improved sort order
testdata/** Updated baselines and test files to align with the new sort order of types
Comments suppressed due to low confidence (1)

internal/checker/types.go:430

  • The reordering of TypeFlags shifts the bit positions for several flags; please verify that all dependent logic and tests are updated accordingly to avoid any inadvertent side effects.
	TypeFlagsNonPrimitive    TypeFlags = 1 << 17 // intrinsic object type

@ahejlsberg ahejlsberg requested a review from RyanCavanaugh June 18, 2025 18:30
function foo(instance: Function | object) {
->foo : (instance: Function | object) => number
->instance : Function | object
+>foo : (instance: object | Function) => number
Copy link
Member

Choose a reason for hiding this comment

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

I can update the submodule's ordering to reflect this change separately.

@ahejlsberg ahejlsberg added this pull request to the merge queue Jun 18, 2025
Merged via the queue into main with commit ad9559e Jun 18, 2025
22 checks passed
@ahejlsberg ahejlsberg deleted the fix-1164 branch June 18, 2025 20:28
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.

Change in type inference for Object.entries()

3 participants