export const initPeer = (t: Chat | Diagnostic, test?: boolean) => {
// bleep bloop ... code here
if (test && t instanceof Diagnostic) {
setupPeerTest(t, p);
} else if (t instanceof Chat) {
setupPeer(t, p);
}
};
this code gives me the TSError. I would have thought that I already forced them to be of one type or another...
src/components/Chat/peer.ts:139:19 - error TS2345: Argument of type 'Chat | Diagnostic' is not assignable to parameter of type 'Diagnostic'.
Type 'Chat' is missing the following properties from type 'Diagnostic': defaultState, browsers, append, isPassed
139 setupPeerTest(t, p);
~
src/components/Chat/peer.ts:141:15 - error TS2345: Argument of type 'Chat | Diagnostic' is not assignable to parameter of type 'Chat'.
Type 'Diagnostic' is missing the following properties from type 'Chat': tickTimer, tabDiv, adapter, default, and 28 more.
141 setupPeer(t, p);
~
instanceofshould act as a typeguard