isomorphic-ws
isomorphic-ws copied to clipboard
Export ClientOptions from 'ws'
The ClientOptions are not currently accessible in TypeScript.
It seems like a problem with: https://github.com/heineiuo/isomorphic-ws/blob/e7d264a562b5c9ad4a939a789c7ba43968f1ac38/index.d.ts#L8
It should be https://github.com/heineiuo/isomorphic-ws/blob/551ed56ad43e3a4b945a74eb4294557877a1c6da/index.d.ts#L8
@paralin Which version of isomorphic-ws
did you used?
@heineiuo currently using 4.0.1 in https://github.com/aperturerobotics/starpc -
I tried importing as import { ClientOptions } from 'isomorphic-ws'
since the same works with 'ws' - but of course, that's not exported currently.
@paralin I didn't get errors with 4.0.1
:
https://codesandbox.io/s/nervous-fire-9hnffn?file=/src/App.tsx
Since you are installing ws anyway, you can use the following code:
import { ClientOptions } from 'ws'
@heineiuo
I guess it's expected now to use export = WebSocket
instead of export default WebSocket
?
@heineiuo
I guess it's expected now to use
export = WebSocket
instead ofexport default WebSocket
?
Yes. I'm going to revert the commit which did not published actually.
Isn't it necessary to add more lines like..
import type { ClientOptions } from 'ws'
export { ClientOptions }
export default WebSocket
Isn't it necessary to add more lines like..
import type { ClientOptions } from 'ws' export { ClientOptions } export default WebSocket
No, it's unnecessary because @types/ws
did export = WebSocket;
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/ea4d4e50e11788ef0a8094d7de564ad2f01dfedd/types/ws/index.d.ts#L377
@JoCat @heineiuo I guess there's some confusion here on what I'm asking...
If I try to do this, it doesn't work:
import { ClientOptions } from 'isomorphic-ws'
Is there something that I'm doing wrong here?
@JoCat @heineiuo I guess there's some confusion here on what I'm asking...
If I try to do this, it doesn't work:
import { ClientOptions } from 'isomorphic-ws'
Is there something that I'm doing wrong here?
Could you provide a minimal project or a codesandbox link (just like I submitted above)?