@@ -36,14 +36,17 @@ export interface ClientOnlyFnWithType<TArgs extends Array<any>, TReturnType>
3636 ) => IsomorphicFn < TArgs , TReturnType , TReturnType >
3737}
3838
39- export interface IsomorphicFnWithType < TArgs extends Array < any > , TReturnType >
40- extends IsomorphicFn < TArgs , TReturnType > {
41- server : (
42- serverImpl : ( ...args : TArgs ) => TReturnType ,
43- ) => ServerOnlyFnWithType < TArgs , TReturnType >
44- client : (
45- clientImpl : ( ...args : TArgs ) => TReturnType ,
46- ) => ClientOnlyFnWithType < TArgs , TReturnType >
39+ export interface IsomorphicFnWithType < TArgs extends Array < any > , TReturnType > {
40+ server : ( serverImpl : ( ...args : TArgs ) => TReturnType ) => {
41+ client : (
42+ clientImpl : ( ...args : TArgs ) => TReturnType ,
43+ ) => IsomorphicFn < TArgs , TReturnType , TReturnType >
44+ }
45+ client : ( clientImpl : ( ...args : TArgs ) => TReturnType ) => {
46+ server : (
47+ serverImpl : ( ...args : TArgs ) => TReturnType ,
48+ ) => IsomorphicFn < TArgs , TReturnType , TReturnType >
49+ }
4750}
4851
4952export interface IsomorphicFnBase extends IsomorphicFn {
@@ -63,10 +66,12 @@ export interface IsomorphicFnBase extends IsomorphicFn {
6366// if we use `createIsomorphicFn` in this library itself, vite tries to execute it before the transformer runs
6467// therefore we must return a dummy function that allows calling `server` and `client` method chains.
6568export function createIsomorphicFn ( ) : IsomorphicFnBase {
66- return {
67- $withType : ( ) => { } ,
69+ const baseFns = {
6870 server : ( ) => ( { client : ( ) => ( ) => { } } ) ,
6971 client : ( ) => ( { server : ( ) => ( ) => { } } ) ,
72+ }
73+ return {
74+ $withType : ( ) => baseFns ,
75+ ...baseFns ,
7076 } as any
7177}
72-
0 commit comments