This commit is contained in:
Stephan Ginthör
2018-01-22 21:47:12 +01:00
3 changed files with 9 additions and 5 deletions

View File

@@ -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);
}
}
}
@@ -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;

View File

@@ -131,13 +131,13 @@ function removeExpectedErrors(errors: string, cwd: string): string {
function isUnexpectedError(cwd: string) {
return (error: string[]) => {
ts.Debug.assertGreaterThanOrEqual(error.length, 1);
const match = error[0].match(/(.+\.ts)\((\d+),\d+\): error TS/);
const match = error[0].match(/(.+\.tsx?)\((\d+),\d+\): error TS/);
if (!match) {
return true;
}
const [, errorFile, lineNumberString] = match;
const lines = fs.readFileSync(path.join(cwd, errorFile), { encoding: "utf8" }).split("\n");
const lineNumber = parseInt(lineNumberString);
const lineNumber = parseInt(lineNumberString) - 1;
ts.Debug.assertGreaterThanOrEqual(lineNumber, 0);
ts.Debug.assertLessThan(lineNumber, lines.length);
const previousLine = lineNumber - 1 > 0 ? lines[lineNumber - 1] : "";

View File

@@ -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"]);