stomp-js / stomp-websocket

Stomp client for Web browsers and node.js apps
https://stomp-js.github.io/stomp-websocket/
Apache License 2.0
141 stars 36 forks source link

Remove reference to NodeJS types in TypeScript definition #14

Closed croes closed 7 years ago

croes commented 7 years ago

I'm using stompjs in a Typescript project targeting the browser. The typescript compiler complains that it can't find the node types referenced in stompjs' TS definition:

ERROR in [at-loader] ./node_modules/@stomp/stompjs/index.d.ts:6:1 
    TS2688: Cannot find type definition file for 'node'.

ERROR in [at-loader] ./node_modules/@stomp/stompjs/index.d.ts:75:77 
    TS2503: Cannot find namespace 'NodeJS'.

ERROR in [at-loader] ./node_modules/@stomp/stompjs/index.d.ts:76:35 
    TS2503: Cannot find namespace 'NodeJS'.

This makes sense, I'm not including the node types as I'm targeting the browser. Unfortunately, the return type of setInterval is different between a browser environment (just a number) and a node environment (a more complex NodeJS.Timer object).

Is there a good reason Stomp exports setInterval and clearInterval? Could these be removed from the TS definition?

kum-deepak commented 7 years ago

The code that handled NodeJS was quite old and not well maintained. In last month I have cleaned up quite a lot of that code. It no longer needs setInterval and clearInterval.

Please use the master version, in that I have removed all the offending lines. The master version is refactored and is not same as currently released.

If it still does not work, please let me know. You are welcome to fork it, and make a pull request :)

croes commented 7 years ago

@kum-deepak , the updated typescript definition works perfectly :+1:

Any ETA when this fix will be available in a release on NPM?

kum-deepak commented 7 years ago

I was out of country so did not want to push then. I am back, so, today or tomorrow.

croes commented 7 years ago

Confirmed fixed in 3.1.1.

Thanks for handling this issue so swiftly! :+1:

kum-deepak commented 6 years ago

Planning for next version of stompjs is on the way. Your participation will be really appreciated, please join at https://github.com/stomp-js/stompjs/issues/1