You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * If `value` is a `WeakRef`, return the dereferenced object, or throw if * it has been garbage collected. Else, return `value`. */functionxderef<T>(value: T): TextendsWeakRef<infer U> ? U : T{if(valueinstanceofWeakRef){constval=value.deref();if(!val){thrownewReferenceError(value);}returnval;}returnvalue;}
🙁 Actual behavior
Compiler reports, on the final return statement return value:
Type 'T' is not assignable to type 'T extends WeakRef ? U : T'.
🙂 Expected behavior
Compiler would recognize that T does not extend WeakRef, thus that T must only be compatible with itself.
The text was updated successfully, but these errors were encountered:
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Compiler reports, on the final return statement
return value
:🙂 Expected behavior
Compiler would recognize that
T
does not extend WeakRef, thus thatT
must only be compatible with itself.The text was updated successfully, but these errors were encountered: