mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-07 05:41:22 -06:00
Improve debug failure for failed node cast (#21539)
This commit is contained in:
parent
1fb3593e61
commit
477cba539b
@ -1454,7 +1454,13 @@ namespace ts {
|
||||
|
||||
export function cast<TOut extends TIn, TIn = any>(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. */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user