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
For some reason type guards to not work if an interface has only optional properties.
interfaceA{foo : number;}functionisA(object: any): object is A{returntrue;}leta: A|boolean;if(isA(a)){a.foo;// compiles}interfaceB{foo? : number;}functionisB(object: any): object is B{returntrue;}letb: B|boolean;if(isB(b)){b.foo;// does not compile because type inference says its `B | boolean`}
For some reason type guards to not work if an interface has only optional properties.