Skip to content

Commit b9a2d7f

Browse files
committed
2 parents d113418 + 5887169 commit b9a2d7f

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5995,7 +5995,9 @@ namespace ts {
59955995
for (const memberType of types) {
59965996
for (const { escapedName } of getAugmentedPropertiesOfType(memberType)) {
59975997
if (!props.has(escapedName)) {
5998-
props.set(escapedName, createUnionOrIntersectionProperty(unionType as UnionType, escapedName));
5998+
const prop = createUnionOrIntersectionProperty(unionType as UnionType, escapedName);
5999+
// May be undefined if the property is private
6000+
if (prop) props.set(escapedName, prop);
59996001
}
60006002
}
60016003
}
@@ -6177,7 +6179,7 @@ namespace ts {
61776179
t;
61786180
}
61796181

6180-
function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol {
6182+
function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: __String): Symbol | undefined {
61816183
let props: Symbol[];
61826184
const isUnion = containingType.flags & TypeFlags.Union;
61836185
const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0;

src/harness/externalCompileRunner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ function removeExpectedErrors(errors: string, cwd: string): string {
131131
function isUnexpectedError(cwd: string) {
132132
return (error: string[]) => {
133133
ts.Debug.assertGreaterThanOrEqual(error.length, 1);
134-
const match = error[0].match(/(.+\.ts)\((\d+),\d+\): error TS/);
134+
const match = error[0].match(/(.+\.tsx?)\((\d+),\d+\): error TS/);
135135
if (!match) {
136136
return true;
137137
}
138138
const [, errorFile, lineNumberString] = match;
139139
const lines = fs.readFileSync(path.join(cwd, errorFile), { encoding: "utf8" }).split("\n");
140-
const lineNumber = parseInt(lineNumberString);
140+
const lineNumber = parseInt(lineNumberString) - 1;
141141
ts.Debug.assertGreaterThanOrEqual(lineNumber, 0);
142142
ts.Debug.assertLessThan(lineNumber, lines.length);
143143
const previousLine = lineNumber - 1 > 0 ? lines[lineNumber - 1] : "";

tests/cases/fourslash/completionsUnion.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
////interface I { x: number; }
44
////interface Many<T> extends ReadonlyArray<T> { extra: number; }
5-
////const x: I | I[] | Many<string> = { /**/ };
5+
////class C { private priv: number; }
6+
////const x: I | I[] | Many<string> | C = { /**/ };
67

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

0 commit comments

Comments
 (0)