I have:
type: 'WEBSOCKET' | 'HTTP_STREAM';
connection: WebSocketType | HTTPStreamType;
where:
interface Header {
key: string;
val: string;
}
export interface WebSocketType {
websocketUrl: string;
}
export interface HTTPStreamType {
streamUrl: string;
method: 'get' | 'put';
headers: Header[];
}
I'm trying:
if (newStream.type === 'WEBSOCKET') {
if (newStream?.connection?.websocketUrl?.length > 0) {
return setIsNextDisabled(false)
}
}
but the error I get is:
Property 'websocketUrl' does not exist on type 'WebSocketType | HTTPStreamType'.
Property 'websocketUrl' does not exist on type 'HTTPStreamType'.
I thought the guard would work, but it doesn't.