Per #9998 and its many offshoots, we have problems analyzing code like this
letx: string|number="OK";mystery(()=>{x=10;});if(x===10){// Error, we believe this to be impossible }The problem is that we don't know if mystery invokes its argument "now" or "later" (or possibly even never!).
The converse problem appears during reads:
letx: string|number= ...;if(typeofx==='string'){// Error, toLowerCase doesn't exist on string | numberletarr=[1,2,3].map(n=>x.toLowerCase());}Proposal is to allow some form of indicating that the function is invoked immediately, e.g.
declarefunctionmystery(arg: immediate()=>void): void;
This would "inline" the function body for the purposes of flow control analysis
Per #9998 and its many offshoots, we have problems analyzing code like this
The problem is that we don't know if
mysteryinvokes its argument "now" or "later" (or possibly even never!).The converse problem appears during reads:
Proposal is to allow some form of indicating that the function is invoked immediately, e.g.
This would "inline" the function body for the purposes of flow control analysis