Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5995,7 +5995,9 @@ namespace ts {
for (const memberType of types) {
for (const { escapedName } of getAugmentedPropertiesOfType(memberType)) {
if (!props.has(escapedName)) {
props.set(escapedName, createUnionOrIntersectionProperty(unionType as UnionType, escapedName));
const prop = createUnionOrIntersectionProperty(unionType as UnionType, escapedName);
// May be undefined if the property is private
if (prop) props.set(escapedName, prop);
}
}
}
Expand Down Expand Up @@ -6177,7 +6179,7 @@ namespace ts {
t;
}

function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol {
function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined {
let props: Symbol[];
const isUnion = containingType.flags & TypeFlags.Union;
const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0;
Expand Down
4 changes: 3 additions & 1 deletion tests/cases/fourslash/completionsUnion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

////interface I { x: number; }
////interface Many<T> extends ReadonlyArray<T> { extra: number; }
////const x: I | I[] | Many<string> = { /**/ };
////class C { private priv: number; }
////const x: I | I[] | Many<string> | C = { /**/ };

// We specifically filter out any array-like types.
// Private members will be excluded by `createUnionOrIntersectionProperty`.
verify.completionsAt("", ["x"]);