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
exportfunctiononeOrAnother<A,B>(one: A,another: B): A|B{returnMath.random()>0.5 ? one : another;}exportfunctiontest<Textendsobject,PextendskeyofT>(whatever: T,name: P): T[P]{constresult=oneOrAnother(whatever[name],'Hello!');// <-- result is clearly string | T[P] as expectedreturnresult;// <-- expected a type error, actual returning string | T[P] instead of T[P] no problem}