Closed Tim4497 closed 8 months ago
Hello @Tim4497!
Thank you! I'm working on it.
Ran into the same problem. TS does not seem to be able to deduct the type correctly.
One needs to specify
event.type === "ping" && event.data
together to make the TS compiler happy.
@binaryminds Any ideas how to solve this?
Please take a look at this PR https://github.com/binaryminds/react-native-sse/pull/29 and let me know if it does resolve this problem.
When I try the example with custom events I get:
es.addEventListener("ping", (event) => { console.log("Received ping with data:", event.data); });
Property 'data' does not exist on type 'EventSourceEvent | CustomEvent<MyCustomEvents>'. Property 'data' does not exist on type 'OpenEvent'.ts(2339)