mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
//// [tests/cases/compiler/assertsPredicateParameterMismatch.ts] ////
|
|
|
|
=== assertsPredicateParameterMismatch.ts ===
|
|
// This test verifies that the checker doesn't panic when an assertion predicate
|
|
// references a parameter name that doesn't match any actual function parameter.
|
|
// This specifically tests the code path in isReachableFlowNodeWorker.
|
|
|
|
function assertCondition(
|
|
>assertCondition : Symbol(assertCondition, Decl(assertsPredicateParameterMismatch.ts, 0, 0))
|
|
|
|
_condition: boolean
|
|
>_condition : Symbol(_condition, Decl(assertsPredicateParameterMismatch.ts, 4, 25))
|
|
|
|
): asserts condition { // "condition" doesn't match parameter "_condition"
|
|
if (!_condition) {
|
|
>_condition : Symbol(_condition, Decl(assertsPredicateParameterMismatch.ts, 4, 25))
|
|
|
|
throw new Error('Condition failed');
|
|
>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --))
|
|
}
|
|
}
|
|
|
|
function test(): void {
|
|
>test : Symbol(test, Decl(assertsPredicateParameterMismatch.ts, 10, 1))
|
|
|
|
assertCondition(false);
|
|
>assertCondition : Symbol(assertCondition, Decl(assertsPredicateParameterMismatch.ts, 0, 0))
|
|
|
|
console.log("unreachable");
|
|
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
|
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
|
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
|
}
|
|
|