From f6e6193e451af0ac1d16a10b8a3e8d7d3f2607c9 Mon Sep 17 00:00:00 2001 From: Max Schwenk Date: Tue, 29 Sep 2026 03:22:09 -0400 Subject: [PATCH] Check intersection properties for never-reduction in a stable order somePropertyReducesToNever ranged over a map, so the combined properties it creates were created in a random order, and when there was more than one candidate, which of them got created before it returned varied between runs. Keep the counts in an OrderedMap so the properties are checked in the order they were found. Co-Authored-By: Claude Opus 5.5 --- tsc/internal/checker/checker.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tsc/internal/checker/checker.go b/tsc/internal/checker/checker.go index 13cb56c69ded6..8ded13641197d 100644 --- a/tsc/internal/checker/checker.go +++ b/tsc/internal/checker/checker.go @@ -22215,14 +22215,15 @@ func (c *Checker) isMappingOfSameObjectType(types []*Type) bool { func (c *Checker) somePropertyReducesToNever(t *Type) bool { // Collect declaration counts for each property across all constituent types of the intersection. - counts := make(map[string]int) + var counts collections.OrderedMap[string, int] for _, t := range t.Types() { for _, prop := range c.getPropertiesOfType(t) { - counts[prop.Name]++ + counts.Set(prop.Name, counts.GetOrZero(prop.Name)+1) } } // Check if any property appears in more than one constituent type and reduces to 'never'. - for propName, count := range counts { + // Go in the order the properties were found so the combined properties are created in the same order every time. + for propName, count := range counts.Entries() { if count > 1 { if prop := c.getPropertyOfUnionOrIntersectionType(t, propName, true /*skipObjectFunctionPropertyAugment*/); prop != nil && c.isNeverReducedProperty(prop) { return true