No type definitions for objectMode?

Open Beginner friendly
#168 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
node.js, typescript

Research direction

Start with the WebSocketStream declaration shown in the issue and trace the ClientOptions type through @types/ws and @types/node. Confirm whether objectMode is supported, then make the declaration accept it and verify that the provided TypeScript example type-checks without an ignore directive.

Written by the indexing model from the issue text.

Description

Somehow, the objectMode option has disappeared in the TypeScript definition. I wonder, it is still supported?

Here is my code:

const stream = websocket(ws, {
  // Important, send each chunk on its own, see
  // https://github.com/maxogden/websocket-stream/issues/117#issuecomment-298826011
  objectMode: true,
});

It produces this error

No overload matches this call.
  Overload 1 of 2, '(target: string | WebSocket, options?: ClientOptions | undefined): WebSocketDuplex', gave the following error.
    Object literal may only specify known properties, and 'objectMode' does not exist in type 'ClientOptions'.
  Overload 2 of 2, '(target: string | WebSocket, protocols?: string | string[] | undefined, options?: ClientOptions | undefined): WebSocketDuplex', gave the following error.
    Object literal may only specify known properties, and 'objectMode' does not exist in type 'string[]'.

I'm using latest websocket-stream version 5.5.2

There is one interesting I've found out in the type declarations:

declare function WebSocketStream(target: string | WebSocket, options?: WebSocket.ClientOptions): WebSocketStream.WebSocketDuplex;

WebSocket.ClientOptions itself stems from @types/ws where the ClientOptions are being extended by SecureContextOptions which comes from @types/node. To me, it seems there are some version mismatches, perhaps?

For now, I will @tsignore it, but am not comfortable about it.

Advice, discussions welcome. Thanks.

Dominant language
JavaScript
Stars
667
Forks
110
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from max-mapper/websocket-stream

All issues in max-mapper/websocket-stream

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.