TypeScript supporting?
maxhis opened this issue ยท 11 comments
Can you make this library support TypeScript, please?
This package has a peer dependency of ws
, so I guess you can install @type/ws
and just add a simple index.d.ts
file in node_modules/isomorphic-ws
folder with content :
import WebSocket from 'ws'
export default WebSocket
Not verified.
If it worked, tell me and I will make a new release ๐
This actually only work for the node.js side of things, as @types/ws
has a dependency on @types/node
this will pull in the node types into a compilation intended for the browser. I'll try to find a solution and submit an issue + PR if I succeed.
When you make "@types/ws" a dependency (not dev dependency) of this project, the hack in
Run
npm install @types/ws
before using this.
is not needed anymore
I get this error:
load script [isomorphic-ws] failed : C:\code\slot\node_modules\ws\lib\websocket.js:347
...options
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (C:\code\slot\node_modules\ws\index.js:3:19)
@linweixiancai your comment seems off topic to me. Please open another issue. You're most likely running this with an ancient version of Nose.js which doesn't interpret the newer version of JavaScript (ES6).
Can you verify, by checking what version of node is running this?
This actually only work for the node.js side of things, as
@types/ws
has a dependency on@types/node
this will pull in the node types into a compilation intended for the browser. I'll try to find a solution and submit an issue + PR if I succeed.
@kraenhansen Hello! I got same issue in browser..
Is there any update on how to make this work in a browser?
I haven't come around to finding a good solution for this. Ideally someone would spend some time writing platform independent types for WebSocket
๐ค (which doesn't reference node
nor dom
lib types).
@kraenhansen Thank you for comment! I will digging more this issue thanks! ๐ค