Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export ClientOptions from 'ws' #27

Open
paralin opened this issue Jun 22, 2022 · 10 comments
Open

Export ClientOptions from 'ws' #27

paralin opened this issue Jun 22, 2022 · 10 comments
Milestone

Comments

@paralin
Copy link

paralin commented Jun 22, 2022

The ClientOptions are not currently accessible in TypeScript.

@heineiuo
Copy link
Owner

heineiuo commented Jun 23, 2022

It seems like a problem with:

export default WebSocket;

It should be

export = WebSocket

@paralin Which version of isomorphic-ws did you used?

@paralin
Copy link
Author

paralin commented Jun 23, 2022

@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.

@heineiuo
Copy link
Owner

@paralin I didn't get errors with 4.0.1:
Screen Shot 2022-06-23 at 13 22 38

https://codesandbox.io/s/nervous-fire-9hnffn?file=/src/App.tsx

@JoCat
Copy link

JoCat commented Jun 23, 2022

Since you are installing ws anyway, you can use the following code:

import { ClientOptions } from 'ws'

@paralin
Copy link
Author

paralin commented Jun 24, 2022

@heineiuo

image

I guess it's expected now to use export = WebSocket instead of export default WebSocket ?

@heineiuo
Copy link
Owner

@heineiuo

image

I guess it's expected now to use export = WebSocket instead of export default WebSocket ?

Yes. I'm going to revert the commit which did not published actually.

@paralin
Copy link
Author

paralin commented Jun 24, 2022

Isn't it necessary to add more lines like..

import type { ClientOptions } from 'ws'

export { ClientOptions }
export default WebSocket

@heineiuo
Copy link
Owner

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

@paralin
Copy link
Author

paralin commented Jun 27, 2022

@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?

@heineiuo
Copy link
Owner

@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)?

@heineiuo heineiuo added this to the v6 milestone Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants