From 477cba539b1da025c3fb27fe6aa99a7772f7fd29 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 1 Feb 2018 10:51:28 -0800 Subject: [PATCH] Improve debug failure for failed node cast (#21539) --- src/compiler/core.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 2966582cb39..c2ede12345f 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1454,7 +1454,13 @@ namespace ts { export function cast(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut { if (value !== undefined && test(value)) return value; - Debug.fail(`Invalid cast. The supplied value did not pass the test '${Debug.getFunctionName(test)}'.`); + + if (value && typeof (value as any).kind === "number") { + Debug.fail(`Invalid cast. The supplied ${(ts as any).SyntaxKind[(value as any).kind]} did not pass the test '${Debug.getFunctionName(test)}'.`); + } + else { + Debug.fail(`Invalid cast. The supplied value did not pass the test '${Debug.getFunctionName(test)}'.`); + } } /** Does nothing. */