Skip to content

fix(js): type useShinyOutputValue() as T | null | undefined; export styles.css - #331

Open
schloerke wants to merge 2 commits into
mainfrom
schloerke/output-value-null
Open

schloerke wants to merge 2 commits into
mainfrom
schloerke/output-value-null

Conversation

@schloerke

@schloerke schloerke commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes posit-dev/shinyreact#329.

A server NULL / None reaches the client as null, but useShinyOutputValue() was typed T | undefined. Code that checked x !== undefined passed the type checker and then crashed at runtime. The return type is now T | null | undefined.

Also from the issue: the stylesheet is now exported as @posit-dev/shinyreact/styles.css too. With the .css name, TypeScript matches a *.css module declaration (for example vite/client), so no declare module is needed. The old ./styles export stays.

Note: the type change may make existing TypeScript callers handle null. That is the point, but it can show up as new type errors on upgrade.

@schloerke
schloerke added this pull request to stack #335 November 9, 2026 18:21
@schloerke schloerke changed the title schloerke/output value null fix(js): type useShinyOutputValue() as T | null | undefined; export styles.css Nov 9, 2026
…tyles.css

A server NULL / None arrives as null, but the hook was typed T | undefined,
so `x !== undefined` narrowed to T and crashed at runtime. Also export the
stylesheet as @posit-dev/shinyreact/styles.css so TypeScript resolves the
import through a *.css module declaration.

Fixes #329
@schloerke
schloerke force-pushed the schloerke/output-value-null branch from 5ca8966 to 4ec44cb Compare November 9, 2026 21:40

This branch has not been deployed

No deployments
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.

useShinyOutputValue() returns null but is typed T | undefined

1 participant