Closed genadis closed 4 years ago
This is an interesting case. It has come up earlier as well. Following is a summary:
dom
lib. So, if the code needs to be typechecked, dom
lib needs to be included in the configuration.Do you have any idea on how to avoid it without compromising type checking abilities?
Since the internal usage of the types is very limited, a few callbacks, send and constructor,
I would suggest defining a minimum interface for the Websocket calling it StompWebsocket
for example.
webSocketFactory
could leverage typescript generics, the default being StompWebsocket
.
The user of the library could path it's own type.
That way as library author you define the minimum required interfaces, and the user could use any compliant websocket library.
@kum-deepak what do you think?
That makes sense. We can try an interface say IWebSocket
with only needed subset of the actual WebSocket interface. Will you take a shot and create a PR?
This opens up another interesting option - for NodeJS users - it is possible to create a thin wrapper over TCP socket for this library to work, avoiding WebSockets completely.
Considering this, we can try the name to be IStompSocket
or ISocket
.
@kum-deepak I've created a pull request, please see if it's ok by you. it should allow full flexibility for wrapping the socket for node and for the browser
Resolved by #224
Please see FAQs at https://stomp-js.github.io/faqs/2019/05/20/faqs.html before reporting.
Thank you for the great project!
My setup is Node.Js + typescript (no webpack). Typescript > 12 I've followed the guide, added 'ws' for websockets support.
in my tsconfig:
When compiling I get a number of errors regarding missing DOM types:
I've tied adding
@types/ws
no luck. But even if it worked, there are still errors regardingEvent
andCloseEvent
.The only workaround that worked for me so far is adding 'dom' to 'libs' of the tsonfig. and probably
skipLibCheck
would have worked as well.It would be great if the library didn't have dependency on the DOM types
Thanks!