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
{{ message }}
Repository navigation
in operator on T & object narrows to neverย #50639
Yes, related to #50531, but not going to be fixed for 4.8.3. 4.8.3 will contain a more minimal fix specific to unknown and {}, while for 4.9 we plan to fix the other examples you show here. Anders Hejlsberg (@ahejlsberg) is actively working on this. Iโm not sure thereโs an existing issue tracking it though, so I guess this is it now.
Reacted by Sam A. Horvath-Hunt, Oliver Joseph Ash and Wลadysลaw Raczek
Activity
erheron commentedon Sep 6, 2022
It's quite interesting though, since if you remove the
"prop" in valueconditionif,valueis inferred asA & objectas expected ๐คOliverJAsh commentedon Sep 6, 2022
Note that even in TS 4.7 using the
inoperator onA & objectreturnednever: https://www.typescriptlang.org/play?ts=4.7.4#code/MYewdgzgLgBAZgJhgXhgHgIIBoB8AKANwEMAbAVwFMAuGDGAMhhACMArC4KAShRxgG8AUDBEwAlnBh5ho2QCIADgCcQCueLAxi5CjJE8hs2dsoBuPUYD0lmAD0A-BYC+gp6aA. This only became an issue after TS 4.8 started narrowingAtoA & object.fatcerberus commentedon Sep 6, 2022
Since this involves narrowing via
in, this might be related to #50531.andrewbranch commentedon Sep 6, 2022
Yes, related to #50531, but not going to be fixed for 4.8.3. 4.8.3 will contain a more minimal fix specific to
unknownand{}, while for 4.9 we plan to fix the other examples you show here. Anders Hejlsberg (@ahejlsberg) is actively working on this. Iโm not sure thereโs an existing issue tracking it though, so I guess this is it now.