diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 664a84ec99a97..2b951a2e60abb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7772,7 +7772,7 @@ namespace ts { } function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined { - let props: Symbol[] | undefined; + const propSet = createMap(); let indexTypes: Type[] | undefined; const isUnion = containingType.flags & TypeFlags.Union; const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0; @@ -7787,7 +7787,10 @@ namespace ts { const modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; - props = appendIfUnique(props, prop); + const id = "" + getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } checkFlags |= (isReadonlySymbol(prop) ? CheckFlags.Readonly : 0) | (!(modifiers & ModifierFlags.NonPublicAccessibilityModifier) ? CheckFlags.ContainsPublic : 0) | (modifiers & ModifierFlags.Protected ? CheckFlags.ContainsProtected : 0) | @@ -7809,9 +7812,10 @@ namespace ts { } } } - if (!props) { + if (!propSet.size) { return undefined; } + const props = arrayFrom(propSet.values()); if (props.length === 1 && !(checkFlags & CheckFlags.Partial) && !indexTypes) { return props[0]; }