Skip to content

docs: warn about empty-object UwsSocketImpl.data cast at class level (#191)#200

Open
mvanhorn wants to merge 1 commit into
FOSSFORGE:mainfrom
mvanhorn:docs/191-uwssocket-data-jsdoc
Open

docs: warn about empty-object UwsSocketImpl.data cast at class level (#191)#200
mvanhorn wants to merge 1 commit into
FOSSFORGE:mainfrom
mvanhorn:docs/191-uwssocket-data-jsdoc

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Summary

UwsSocketImpl initializes _data = {} as TData in its constructor. That cast is safe for object TData without required fields (the common case), but it silently lies for primitive TData or types with required properties: socket.data then reads as {} typed at TData, and the caller is none the wiser.

The data getter already mentions this caveat, but readers browsing the class for an API overview easily miss the per-property note. Lift the warning to the class-level JSDoc so it shows up in IntelliSense, generated API docs, and the rendered class documentation alongside the rest of the description.

Changes

  • src/websocket/core/socket.ts: extend the UwsSocketImpl class JSDoc with the "set socket.data before reading it for primitive / required-field TData" caveat lifted from the data getter's existing note.

Closes #191

…OSSFORGE#191)

`UwsSocketImpl` initializes `_data = {} as TData` in its constructor.
That cast is safe for object `TData` without required fields, but it
silently lies for primitive `TData` or types with required properties:
`socket.data` then reads as `{}` typed at `TData`, and the caller is
none the wiser. The `data` getter already mentions this, but readers
browsing the class for an API overview can miss the per-property note.

Lift the warning to the class-level JSDoc so it shows up in IntelliSense
and the rendered API docs alongside the rest of the class description.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 26264dc7-1501-4898-bbd9-ec18702f2c2d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Successfully merging this pull request may close these issues.

Add class-level JSDoc warning for UwsSocketImpl data initialization

1 participant