Closed
Description
π Search Terms
- 5.5 predicate
- 6133
π Version & Regression Information
- This changed between versions 5.4.5 and 5.5.0-beta
β― Playground Link
π» Code
function predWithUnused(a: unknown) {
return !!Math.random();
}
π Actual behavior
TS 5.5.0-beta reports that a
is used.
π Expected behavior
It should be reported as unused.
Additional information about the issue
Compare 5.4.5

vs. 5.5.0-beta:

This was almost certainly broken by #57465. It adds a call to getTypeOfSymbol
for every parameter of a candidate predicate function in checkIfExpressionRefinesAnyParameter
. This marks each of those parameters as referenced, even though there's no reason to assume that they are, since this call is speculative.
This also affects the "Delete all unused declarations" quickfix.