-
Notifications
You must be signed in to change notification settings - Fork 764
Reorder TypeFlags to improve sort order
#1226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
| function foo(instance: Function | object) { | ||
| ->foo : (instance: Function | object) => number | ||
| ->instance : Function | object | ||
| +>foo : (instance: object | Function) => number |
There was a problem hiding this comment.
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.
This PR reorders the
TypeFlagsenum such thatobjecttype sorts before actual object types, andThis fixes #1164 and also ensures that union subtype reduction prefers non-intersections over intersections when types are mutual subtypes.
Fixes #1164.