Skip to content

Commit 4bd698b

Browse files
committed
Use aliases when available in error reporting
1 parent 0d99ec1 commit 4bd698b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14553,13 +14553,13 @@ namespace ts {
1455314553
* * Ternary.Maybe if they are related with assumptions of other relationships, or
1455414554
* * Ternary.False if they are not related.
1455514555
*/
14556-
function isRelatedTo(source: Type, target: Type, reportErrors = false, headMessage?: DiagnosticMessage, isApparentIntersectionConstituent?: boolean): Ternary {
14556+
function isRelatedTo(originalSource: Type, originalTarget: Type, reportErrors = false, headMessage?: DiagnosticMessage, isApparentIntersectionConstituent?: boolean): Ternary {
1455714557
// Normalize the source and target types: Turn fresh literal types into regular literal types,
1455814558
// turn deferred type references into regular type references, simplify indexed access and
1455914559
// conditional types, and resolve substitution types to either the substitution (on the source
1456014560
// side) or the type variable (on the target side).
14561-
source = getNormalizedType(source, /*writing*/ false);
14562-
target = getNormalizedType(target, /*writing*/ true);
14561+
let source = getNormalizedType(originalSource, /*writing*/ false);
14562+
let target = getNormalizedType(originalTarget, /*writing*/ true);
1456314563

1456414564
// Try to see if we're relating something like `Foo` -> `Bar | null | undefined`.
1456514565
// If so, reporting the `null` and `undefined` in the type is hardly useful.
@@ -14692,6 +14692,8 @@ namespace ts {
1469214692
}
1469314693

1469414694
if (!result && reportErrors) {
14695+
source = originalSource.aliasSymbol ? originalSource : source;
14696+
target = originalTarget.aliasSymbol ? originalTarget : target;
1469514697
let maybeSuppress = overrideNextErrorInfo > 0;
1469614698
if (maybeSuppress) {
1469714699
overrideNextErrorInfo--;

0 commit comments

Comments
 (0)