@@ -23,20 +23,24 @@ interface Config<S, U> extends Partial<ScopeConfig> {
2323 selector ?: ( state : S ) => U
2424}
2525
26- export function useAyanami < M extends Ayanami < S > , S , U = M extends Ayanami < infer SS > ? SS : S > (
26+ export function useAyanami < M extends Ayanami < any > , U = M extends Ayanami < infer S > ? S : never > (
2727 A : ConstructorOf < M > ,
28- config ?: M extends Ayanami < infer SS > ? Config < SS , U > : Config < S , U > ,
29- ) : M extends Ayanami < infer SS > ? Result < M , SS , U > : Result < M , S , U > {
28+ config ?: M extends Ayanami < infer S > ? Config < S , U > : never ,
29+ ) : M extends Ayanami < infer S >
30+ ? NonNullable < typeof config > extends Config < S , infer SS >
31+ ? Result < M , S , SS >
32+ : Result < M , S , S >
33+ : never {
3034 const scope = get ( config , 'scope' )
3135 const selector = get ( config , 'selector' )
3236 const req = isSSREnabled ( ) ? React . useContext ( SSRContext ) : null
3337 const reqScope = req ? createScopeWithRequest ( req , scope ) : scope
3438 const ayanami = React . useMemo ( ( ) => getInstanceWithScope ( A , reqScope ) , [ reqScope ] )
3539 ayanami . scopeName = scope || DEFAULT_SCOPE_NAME
3640
37- const useAyanamiInstanceConfig = React . useMemo ( ( ) : UseAyanamiInstanceConfig < S , U > => {
41+ const useAyanamiInstanceConfig = React . useMemo < UseAyanamiInstanceConfig > ( ( ) => {
3842 return { destroyWhenUnmount : scope === TransientScope , selector }
3943 } , [ reqScope ] )
4044
41- return useAyanamiInstance < M , S , U > ( ayanami , useAyanamiInstanceConfig ) as any
45+ return useAyanamiInstance ( ayanami , useAyanamiInstanceConfig ) as any
4246}
0 commit comments