Skip to content

Conversation

@rschristian
Copy link
Member

@rschristian rschristian commented Nov 13, 2025

Ran into this at work, it'd be nice if you could pass in any ComponentChild-compatible content for our util components as both their fallbacks & children. At the moment it's a type error:

function Comp() {
  return (
    <Show when={count}>
      'hello'
  {/* ^ 'Show' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of 'children' is 'Element | ((value: boolean) => Element)'.(2747) */}
    </Show>
  )
}

cc @bluetidepro

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

🦋 Changeset detected

Latest commit: 4cd3d4a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@preact/signals Patch
@preact/signals-react Patch
preact-signals-devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Nov 13, 2025

Deploy Preview for preact-signals-demo ready!

Name Link
🔨 Latest commit 4cd3d4a
🔍 Latest deploy log https://app.netlify.com/projects/preact-signals-demo/deploys/691794dad2b1df0008accef8
😎 Deploy Preview https://deploy-preview-795--preact-signals-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@rschristian rschristian marked this pull request as draft November 13, 2025 16:03
@rschristian rschristian force-pushed the types/util-comp-types branch from 12b6c65 to 91a2c2d Compare November 14, 2025 01:57
@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

Size Change: 0 B

Total Size: 106 kB

ℹ️ View Unchanged
Filename Size
docs/dist/assets/bench.********.js 1.59 kB
docs/dist/assets/client.********.js 46.2 kB
docs/dist/assets/devtools.********.js 1.03 kB
docs/dist/assets/index.********.js 7.04 kB
docs/dist/assets/jsxRuntime.module.********.js 297 B
docs/dist/assets/preact.module.********.js 4.72 kB
docs/dist/assets/signals-core.module.********.js 1.56 kB
docs/dist/assets/signals.module.********.js 2.57 kB
docs/dist/assets/style.********.css 1.27 kB
docs/dist/assets/style.********.js 21 B
docs/dist/basic-********.js 245 B
docs/dist/nesting-********.js 1.13 kB
docs/dist/react-********.js 242 B
packages/core/dist/signals-core.js 1.59 kB
packages/core/dist/signals-core.mjs 1.6 kB
packages/debug/dist/debug.js 3.64 kB
packages/debug/dist/debug.mjs 3.18 kB
packages/preact-transform/dist/signals-*********.js 1.3 kB
packages/preact-transform/dist/signals-transform.mjs 1.29 kB
packages/preact-transform/dist/signals-transform.umd.js 1.42 kB
packages/preact/dist/signals.js 1.71 kB
packages/preact/dist/signals.mjs 1.67 kB
packages/react-transform/dist/signals-*********.js 6.89 kB
packages/react-transform/dist/signals-transform.mjs 6.09 kB
packages/react-transform/dist/signals-transform.umd.js 7.01 kB
packages/react/dist/signals.js 188 B
packages/react/dist/signals.mjs 150 B

compressed-size-action

const value =
typeof props.when === "function" ? props.when() : props.when.value;
if (!value) return props.fallback || null;
if (!value) return (props.fallback as JSX.Element) || null;
Copy link
Member Author

@rschristian rschristian Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the correct approach for React's types? Weird: microsoft/TypeScript#14729

If there's a better way lmk

@rschristian rschristian marked this pull request as ready for review November 14, 2025 02:13
@bluetidepro
Copy link

Glad we stumbled upon this. Nice fix!

@rschristian rschristian force-pushed the types/util-comp-types branch from 16280ee to 4cd3d4a Compare November 14, 2025 20:45
@rschristian rschristian merged commit 80712b1 into main Nov 14, 2025
6 checks passed
@rschristian rschristian deleted the types/util-comp-types branch November 14, 2025 20:48
@github-actions github-actions bot mentioned this pull request Nov 14, 2025
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.

4 participants