Skip to content

Commit 1d70b01

Browse files
committed
Address CR feedback
1 parent c427a46 commit 1d70b01

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17997,16 +17997,16 @@ namespace ts {
1799717997
return {
1799817998
errorInfo,
1799917999
lastSkippedInfo,
18000-
incompatibleStack: incompatibleStack ? incompatibleStack.slice() : undefined,
18000+
incompatibleStack: incompatibleStack?.slice(),
1800118001
overrideNextErrorInfo,
18002-
relatedInfo: relatedInfo ? relatedInfo.slice() as [DiagnosticRelatedInformation, ...DiagnosticRelatedInformation[]] : undefined,
18002+
relatedInfo: relatedInfo?.slice() as [DiagnosticRelatedInformation, ...DiagnosticRelatedInformation[]] | undefined,
1800318003
};
1800418004
}
1800518005

1800618006
function reportIncompatibleError(message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number) {
1800718007
overrideNextErrorInfo++; // Suppress the next relation error
1800818008
lastSkippedInfo = undefined; // Reset skipped info cache
18009-
(incompatibleStack || (incompatibleStack = [])).push([message, arg0, arg1, arg2, arg3]);
18009+
(incompatibleStack ||= []).push([message, arg0, arg1, arg2, arg3]);
1801018010
}
1801118011

1801218012
function reportIncompatibleStack() {
@@ -18579,18 +18579,9 @@ namespace ts {
1857918579
}
1858018580
}
1858118581
// Check to see if any constituents of the intersection are immediately related to the target.
18582-
//
18583-
// Don't report errors though. Checking whether a constituent is related to the source is not actually
18584-
// useful and leads to some confusing error messages. Instead it is better to let the below checks
18585-
// take care of this, or to not elaborate at all. For instance,
18586-
//
18587-
// - For an object type (such as 'C = A & B'), users are usually more interested in structural errors.
18588-
//
18589-
// - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection
18590-
// than to report that 'D' is not assignable to 'A' or 'B'.
18591-
//
18592-
// - For a primitive type or type parameter (such as 'number = A & B') there is no point in
18593-
// breaking the intersection apart.
18582+
// Don't report errors though. Elaborating on whether a source constituent is related to the target is
18583+
// not actually useful and leads to some confusing error messages. Instead, we rely on the caller
18584+
// checking whether the full intersection viewed as an object is related to the target.
1859418585
return someTypeRelatedToType(source as IntersectionType, target, /*reportErrors*/ false, IntersectionState.Source);
1859518586
}
1859618587

0 commit comments

Comments
 (0)