solidjs / solid

A declarative, efficient, and flexible JavaScript library for building user interfaces.
https://solidjs.com
MIT License
32.05k stars 914 forks source link

`props.children` not available in type Component<T> #985

Closed yw662 closed 2 years ago

yw662 commented 2 years ago

Describe the bug

It is solid 1.4.1 (with ^1.3.x in package.json) Within code:

import { Component } from 'solid-js'

export const Tmp: Component<{
  n: number
}> = props => {
  return <>
    {props.children}
  </>
}

TypeScript complaints that there is no children on props.

Your Example Website or App

localhost

Steps to Reproduce the Bug or Issue

as shown above.

Expected behavior

It might be a breaking change or sth, but I cannot find it in the doc. Should I always explicitly define it when a component need children ?

Screenshots or Videos

No response

Platform

Additional context

No response

yw662 commented 2 years ago

yeah it is documented in #887. I hope it can be find somewhere in the doc.

edemaine commented 2 years ago

Yes: https://www.solidjs.com/guides/typescript#component-types (and the change log)

Glad you found it though!