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
I am not sure if this is exactly similar, but I am getting property doesn't exist on never
abstractclassGuards{publicstaticisBasic(obj: Base): obj is Basic{returnobj.type===Type.Basic;}publicstaticisChainage(obj: Base): obj is Chainage{returnobj.type===Type.Chainage;}}enumType{Basic,Chainage,}interfaceBase{type: Type,}interfaceBasicextendsBase{}interfaceChainageextendsBase{start: number;end: number;}constref: Chainage={type: Type.Chainage,start: 0,end: 1,}if(Guards.isBasic(ref)){// No-op}elseif(Guards.isChainage(ref)){ref.start// Property 'start' does not exist on 'never'.}
If the type of the member checked is not falsy (and so is
never
in the false branch).TypeScript Version: 2.7.0-dev.201xxxxx
Code
Expected behavior:
type of
x
in theelse
branch isnever
.Actual behavior:
type of
x
is{a: 1. b: 2}
, andx.a
is (counterintuitively)never
.This would bring the behavior of truthiness guards in line with our new behavior for
in
type guards.The text was updated successfully, but these errors were encountered: