1
- import { ComponentChildren , createSignal , Fiber , PublicSignal } from "../index" ;
1
+ import { ComponentChild , createSignal , PublicSignal } from "../index" ;
2
2
3
3
declare const FRAGMENT = "FRAGMENT" ;
4
4
@@ -11,10 +11,8 @@ export function lazy<T extends (props: any) => any>(
11
11
importFn : ( ) => Promise < { default : T } >
12
12
) : (
13
13
props : PropsOf < T > & {
14
- fallback ?: ComponentChildren ;
15
- errorFallback ?:
16
- | ComponentChildren
17
- | ( ( error : Error ) => ComponentChildren ) ;
14
+ fallback ?: ComponentChild ;
15
+ errorFallback ?: ComponentChild | ( ( error : Error ) => ComponentChild ) ;
18
16
}
19
17
) => ReturnType < T > {
20
18
let Component : T | null = null ;
@@ -64,27 +62,6 @@ export function lazy<T extends (props: any) => any>(
64
62
const error = createSignal < Error | null > ( null ) ;
65
63
66
64
load ( loading , error ) ;
67
- // Validate fallback and errorFallback types
68
- const isValidNode = ( val : any ) =>
69
- typeof val === "string" ||
70
- ( val && typeof val === "object" && "props" in val && "type" in val ) ;
71
-
72
- if ( props . fallback !== undefined && ! isValidNode ( props . fallback ) ) {
73
- throw new Error (
74
- "Invalid fallback: Expected a string or a valid JSX node."
75
- ) ;
76
- }
77
- if (
78
- props . errorFallback !== undefined &&
79
- ! (
80
- typeof props . errorFallback === "function" ||
81
- isValidNode ( props . errorFallback )
82
- )
83
- ) {
84
- throw new Error (
85
- "Invalid errorFallback: Expected a string, a valid JSX node, or a function returning a JSX node."
86
- ) ;
87
- }
88
65
89
66
return (
90
67
< >
0 commit comments