Files
tsgo/testdata/tests/cases/compiler/assertsPredicateParameterMismatch.ts
b33ab79ed5 Fix panic on negative parameterIndex in type predicate flow analysis (#2122)
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: RyanCavanaugh <[email protected]>
Co-authored-by: Ryan Cavanaugh <[email protected]>
2025-11-19 17:34:00 +00:00

20 lines
544 B
TypeScript

// @strict: true
// @noemit: true
// 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(
_condition: boolean
): asserts condition { // "condition" doesn't match parameter "_condition"
if (!_condition) {
throw new Error('Condition failed');
}
}
function test(): void {
assertCondition(false);
console.log("unreachable");
}