@@ -10477,10 +10477,10 @@ namespace ts {
1047710477 }
1047810478
1047910479 function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined {
10480- const propSet = createMap<Symbol>();
10480+ let singleProp: Symbol | undefined;
10481+ let propSet: Map<Symbol> | undefined;
1048110482 let indexTypes: Type[] | undefined;
1048210483 const isUnion = containingType.flags & TypeFlags.Union;
10483- const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0;
1048410484 // Flags we want to propagate to the result if they exist in all source symbols
1048510485 let optionalFlag = isUnion ? SymbolFlags.None : SymbolFlags.Optional;
1048610486 let syntheticFlag = CheckFlags.SyntheticMethod;
@@ -10490,16 +10490,25 @@ namespace ts {
1049010490 if (!(type === errorType || type.flags & TypeFlags.Never)) {
1049110491 const prop = getPropertyOfType(type, name);
1049210492 const modifiers = prop ? getDeclarationModifierFlagsFromSymbol(prop) : 0;
10493- if (prop && !(modifiers & excludeModifiers) ) {
10493+ if (prop) {
1049410494 if (isUnion) {
1049510495 optionalFlag |= (prop.flags & SymbolFlags.Optional);
1049610496 }
1049710497 else {
1049810498 optionalFlag &= prop.flags;
1049910499 }
10500- const id = "" + getSymbolId(prop);
10501- if (!propSet.has(id)) {
10502- propSet.set(id, prop);
10500+ if (!singleProp) {
10501+ singleProp = prop;
10502+ }
10503+ else if (prop !== singleProp) {
10504+ if (!propSet) {
10505+ propSet = createMap<Symbol>();
10506+ propSet.set("" + getSymbolId(singleProp), singleProp);
10507+ }
10508+ const id = "" + getSymbolId(prop);
10509+ if (!propSet.has(id)) {
10510+ propSet.set(id, prop);
10511+ }
1050310512 }
1050410513 checkFlags |= (isReadonlySymbol(prop) ? CheckFlags.Readonly : 0) |
1050510514 (!(modifiers & ModifierFlags.NonPublicAccessibilityModifier) ? CheckFlags.ContainsPublic : 0) |
@@ -10526,13 +10535,15 @@ namespace ts {
1052610535 }
1052710536 }
1052810537 }
10529- if (!propSet.size) {
10538+ if (!singleProp || isUnion && (propSet || checkFlags & CheckFlags.Partial) && checkFlags & (CheckFlags.ContainsPrivate | CheckFlags.ContainsProtected)) {
10539+ // No property was found, or, in a union, a property has a private or protected declaration in one
10540+ // constituent, but is missing or has a different declaration in another constituent.
1053010541 return undefined;
1053110542 }
10532- const props = arrayFrom(propSet.values());
10533- if (props.length === 1 && !(checkFlags & CheckFlags.ReadPartial) && !indexTypes) {
10534- return props[0];
10543+ if (!propSet && !(checkFlags & CheckFlags.ReadPartial) && !indexTypes) {
10544+ return singleProp;
1053510545 }
10546+ const props = propSet ? arrayFrom(propSet.values()) : [singleProp];
1053610547 let declarations: Declaration[] | undefined;
1053710548 let firstType: Type | undefined;
1053810549 let nameType: Type | undefined;
0 commit comments