File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ export type ComponentProps<
87
87
: never ;
88
88
89
89
export interface FunctionComponent < P = { } > {
90
- ( props : RenderableProps < P > , context ?: any ) : VNode < any > | null ;
90
+ ( props : RenderableProps < P > , context ?: any ) : ComponentChild ;
91
91
displayName ?: string ;
92
92
defaultProps ?: Partial < P > ;
93
93
}
Original file line number Diff line number Diff line change 4
4
import {
5
5
ClassAttributes ,
6
6
Component ,
7
+ ComponentChild ,
8
+ ComponentType ,
9
+ FunctionComponent ,
7
10
PreactDOMAttributes ,
8
11
VNode
9
12
} from './index' ;
@@ -26,9 +29,14 @@ export namespace JSXInternal {
26
29
key ?: any ;
27
30
}
28
31
29
- export interface Element extends VNode < any > { }
30
-
31
- export interface ElementClass extends Component < any , any > { }
32
+ export type ElementType < P = any > =
33
+ | {
34
+ [ K in keyof IntrinsicElements ] : P extends IntrinsicElements [ K ]
35
+ ? K
36
+ : never ;
37
+ } [ keyof IntrinsicElements ]
38
+ | ComponentType < P > ;
39
+ export type ElementClass = Component < any , any > | FunctionComponent < any > ;
32
40
33
41
export interface ElementAttributesProperty {
34
42
props : any ;
Original file line number Diff line number Diff line change @@ -102,6 +102,22 @@ const UseOfComponentWithChildren = () => {
102
102
) ;
103
103
} ;
104
104
105
+ const DummyChildren : FunctionalComponent = ( { children } ) => {
106
+ return children ;
107
+ } ;
108
+
109
+ function ReturnChildren ( props : { children : preact . ComponentChildren } ) {
110
+ return props . children ;
111
+ }
112
+
113
+ function TestUndefinedChildren ( ) {
114
+ return (
115
+ < ReturnChildren >
116
+ < ReturnChildren > Hello</ ReturnChildren >
117
+ </ ReturnChildren >
118
+ ) ;
119
+ }
120
+
105
121
// using ref and or jsx
106
122
class ComponentUsingRef extends Component < any , any > {
107
123
private array : string [ ] ;
You can’t perform that action at this time.
0 commit comments