Skip to content

Commit 4b96199

Browse files
authored
[TS] Narrow types for Show utility in React (#711)
* [TS] Narrow types for Show utility in React * Add changeset
1 parent eb4fa82 commit 4b96199

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/orange-moles-trade.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@preact/signals-react": patch
3+
---
4+
5+
Narrow types for Show utility, the callback is truthy by design

packages/react/utils/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Fragment, createElement, useMemo } from "react";
66
interface ShowProps<T = boolean> {
77
when: Signal<T> | ReadonlySignal<T>;
88
fallback?: JSX.Element;
9-
children: JSX.Element | ((value: T) => JSX.Element);
9+
children: JSX.Element | ((value: NonNullable<T>) => JSX.Element);
1010
}
1111

1212
export function Show<T = boolean>(props: ShowProps<T>): JSX.Element | null {

0 commit comments

Comments
 (0)