Skip to content

Commit d18e4aa

Browse files
committed
chore: type unused children as never in nanoviews-component skill
1 parent 6b7486a commit d18e4aa

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎skills/nanoviews-component/SKILL.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export interface DiscountProps {
227227
expired: Signalish<boolean>
228228
}
229229

230-
export const Discount = component$((props: DiscountProps) => {
230+
export const Discount = component$((props: DiscountProps, _children: never) => {
231231
const {
232232
$value,
233233
$expired
@@ -362,6 +362,16 @@ If the project's linter rejects this layout, or its `--fix` collapses it back, t
362362
const Table = component$((props, children) => table(props)(...children))
363363
```
364364

365+
- A component that takes no children declares them as `_children: never`, so a children call on it is a type error instead of silently dropped output:
366+
367+
```ts
368+
// not
369+
component$((props: SomeProps) => ...)
370+
371+
// but
372+
component$((props: SomeProps, _children: never) => ...)
373+
```
374+
365375
- Universal components must forward all remaining props to the root element, spreading `...restProps` after the attributes the component owns — see the reference `Button` above: `type`, `disabled`, `onClick` etc. reach `<button>` via the spread instead of being listed one by one.
366376
- Don't pass unneeded props to the root element — read the props consumed by a helper as `$name`, which is what takes them out of the rest:
367377

0 commit comments

Comments
 (0)