@@ -10353,7 +10353,8 @@ namespace ts {
10353
10353
}
10354
10354
10355
10355
function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined {
10356
- const propSet = createMap<Symbol>();
10356
+ let singleProp: Symbol | undefined;
10357
+ let propSet: Map<Symbol> | undefined;
10357
10358
let indexTypes: Type[] | undefined;
10358
10359
const isUnion = containingType.flags & TypeFlags.Union;
10359
10360
const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0;
@@ -10373,9 +10374,18 @@ namespace ts {
10373
10374
else {
10374
10375
optionalFlag &= prop.flags;
10375
10376
}
10376
- const id = "" + getSymbolId(prop);
10377
- if (!propSet.has(id)) {
10378
- propSet.set(id, prop);
10377
+ if (!singleProp) {
10378
+ singleProp = prop;
10379
+ }
10380
+ else if (prop !== singleProp) {
10381
+ if (!propSet) {
10382
+ propSet = createMap<Symbol>();
10383
+ propSet.set("" + getSymbolId(singleProp), singleProp);
10384
+ }
10385
+ const id = "" + getSymbolId(prop);
10386
+ if (!propSet.has(id)) {
10387
+ propSet.set(id, prop);
10388
+ }
10379
10389
}
10380
10390
checkFlags |= (isReadonlySymbol(prop) ? CheckFlags.Readonly : 0) |
10381
10391
(!(modifiers & ModifierFlags.NonPublicAccessibilityModifier) ? CheckFlags.ContainsPublic : 0) |
@@ -10402,13 +10412,13 @@ namespace ts {
10402
10412
}
10403
10413
}
10404
10414
}
10405
- if (!propSet.size ) {
10415
+ if (!singleProp ) {
10406
10416
return undefined;
10407
10417
}
10408
- const props = arrayFrom(propSet.values());
10409
- if (props.length === 1 && !(checkFlags & CheckFlags.ReadPartial) && !indexTypes) {
10410
- return props[0];
10418
+ if (!propSet && !(checkFlags & CheckFlags.ReadPartial) && !indexTypes) {
10419
+ return singleProp;
10411
10420
}
10421
+ const props = propSet ? arrayFrom(propSet.values()) : [singleProp];
10412
10422
let declarations: Declaration[] | undefined;
10413
10423
let firstType: Type | undefined;
10414
10424
let nameType: Type | undefined;
0 commit comments