Skip to content

Add null to lastJsonMessage type#258

Open
s-h-a-d-o-w wants to merge 1 commit into
robtaussig:masterfrom
s-h-a-d-o-w:patch-1
Open

Add null to lastJsonMessage type#258
s-h-a-d-o-w wants to merge 1 commit into
robtaussig:masterfrom
s-h-a-d-o-w:patch-1

Conversation

@s-h-a-d-o-w

@s-h-a-d-o-w s-h-a-d-o-w commented Jan 2, 2025

Copy link
Copy Markdown

The user has no control over the fact that on first render, lastJsonMessage will be null. And it always is like that (I suspect. Without digging through the code, I don't imagine there's a scenario where the socket is established and sets the value quickly enough for it not to be?).

And so I would argue that the user should have no option of not including null. They might also wrongly assume that undefined is used.

@PrakashC1

Copy link
Copy Markdown

I was surprised — the documentation states the type is T | null, but in the actual library, null isn’t included. However, during the initial load, lastJsonMessage is actually null

After enabling the ESLint rule @typescript-eslint/no-unnecessary-condition, it started flagging all my null checks as unnecessary.

@cadonau

cadonau commented Jul 2, 2025

Copy link
Copy Markdown

I was surprised — the documentation states the type is T | null, but in the actual library, null isn’t included. […]

I just noticed (/ran into) the same.

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.

3 participants