Open
Description
Bug Report
π Search Terms
referenced directly or indirectly asserts
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
declare const myRequire: ((p: string) => {} | undefined) | undefined;
declare function assertIsDefined<T>(value: T): asserts value is NonNullable<T>
function fn1() {
if (!myRequire) {
return;
}
for (const p of ["a", "b"]) {
// Error?
const result = myRequire("something");
assertIsDefined(result);
}
}
π Actual behavior
result
is claimed to be referenced directly or indirectly in its initializer.
Modifying the code in various ways makes the error go away.
π Expected behavior
No error; there's no relationship between the initializer and the result.