Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
KATT committed Mar 1, 2024
1 parent 0e1f7ee commit 8f2a0a7
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 114 deletions.
16 changes: 11 additions & 5 deletions examples/next-prisma-websockets-starter/src/server/routers/post.ts
Expand Up @@ -14,13 +14,19 @@ interface MyEvents {
isTypingUpdate: () => void;
}
declare interface MyEventEmitter {
on<TEv extends keyof MyEvents>(event: TEv, listener: MyEvents[TEv]): this;
off<TEv extends keyof MyEvents>(event: TEv, listener: MyEvents[TEv]): this;
once<TEv extends keyof MyEvents>(event: TEv, listener: MyEvents[TEv]): this;
emit<TEv extends keyof MyEvents>(
on: <TEv extends keyof MyEvents>(event: TEv, listener: MyEvents[TEv]) => this;
off: <TEv extends keyof MyEvents>(
event: TEv,
listener: MyEvents[TEv],
) => this;
once: <TEv extends keyof MyEvents>(
event: TEv,
listener: MyEvents[TEv],
) => this;
emit: <TEv extends keyof MyEvents>(
event: TEv,
...args: Parameters<MyEvents[TEv]>
): boolean;
) => boolean;
}

class MyEventEmitter extends EventEmitter {}
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/createTRPCNext.tsx
Expand Up @@ -33,11 +33,11 @@ export interface CreateTRPCNextBase<
*
* @link https://trpc.io/docs/v11/client/react/useUtils
*/
useContext(): CreateReactUtils<TRouter, TSSRContext>;
useContext: () => CreateReactUtils<TRouter, TSSRContext>;
/**
* @link https://trpc.io/docs/v11/client/react/useUtils
*/
useUtils(): CreateReactUtils<TRouter, TSSRContext>;
useUtils: () => CreateReactUtils<TRouter, TSSRContext>;
withTRPC: ReturnType<typeof withTRPC<TRouter, TSSRContext>>;
useQueries: TRPCUseQueries<TRouter>;
useSuspenseQueries: TRPCUseSuspenseQueries<TRouter>;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-query/src/createTRPCReact.tsx
Expand Up @@ -231,11 +231,11 @@ export type CreateTRPCReactBase<TRouter extends AnyRouter, TSSRContext> = {
*
* @link https://trpc.io/docs/v11/client/react/useUtils
*/
useContext(): CreateReactUtils<TRouter, TSSRContext>;
useContext: () => CreateReactUtils<TRouter, TSSRContext>;
/**
* @link https://trpc.io/docs/v11/client/react/useUtils
*/
useUtils(): CreateReactUtils<TRouter, TSSRContext>;
useUtils: () => CreateReactUtils<TRouter, TSSRContext>;
Provider: TRPCProvider<TRouter, TSSRContext>;
createClient: CreateClient<TRouter>;
useQueries: TRPCUseQueries<TRouter>;
Expand Down
16 changes: 8 additions & 8 deletions packages/react-query/src/server/ssgProxy.ts
Expand Up @@ -59,25 +59,25 @@ type DecorateProcedure<
/**
* @link https://tanstack.com/query/v5/docs/framework/react/guides/prefetching
*/
fetch(
fetch: (
input: inferProcedureInput<TProcedure>,
opts?: TRPCFetchQueryOptions<
inferTransformedProcedureOutput<TRoot, TProcedure>,
TRPCClientError<TRoot>
>,
): Promise<inferTransformedProcedureOutput<TRoot, TProcedure>>;
) => Promise<inferTransformedProcedureOutput<TRoot, TProcedure>>;

/**
* @link https://tanstack.com/query/v5/docs/framework/react/guides/prefetching
*/
fetchInfinite(
fetchInfinite: (
input: inferProcedureInput<TProcedure>,
opts?: TRPCFetchInfiniteQueryOptions<
inferProcedureInput<TProcedure>,
inferTransformedProcedureOutput<TRoot, TProcedure>,
TRPCClientError<TRoot>
>,
): Promise<
) => Promise<
InfiniteData<
inferTransformedProcedureOutput<TRoot, TProcedure>,
NonNullable<ExtractCursorType<inferProcedureInput<TProcedure>>> | null
Expand All @@ -87,25 +87,25 @@ type DecorateProcedure<
/**
* @link https://tanstack.com/query/v5/docs/framework/react/guides/prefetching
*/
prefetch(
prefetch: (
input: inferProcedureInput<TProcedure>,
opts?: TRPCFetchQueryOptions<
inferTransformedProcedureOutput<TRoot, TProcedure>,
TRPCClientError<TRoot>
>,
): Promise<void>;
) => Promise<void>;

/**
* @link https://tanstack.com/query/v5/docs/framework/react/guides/prefetching
*/
prefetchInfinite(
prefetchInfinite: (
input: inferProcedureInput<TProcedure>,
opts?: TRPCFetchInfiniteQueryOptions<
inferProcedureInput<TProcedure>,
inferTransformedProcedureOutput<TRoot, TProcedure>,
TRPCClientError<TRoot>
>,
): Promise<void>;
) => Promise<void>;
};

/**
Expand Down
56 changes: 28 additions & 28 deletions packages/react-query/src/shared/proxy/utilsProxy.ts
Expand Up @@ -45,25 +45,25 @@ type DecorateProcedure<
/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientfetchquery
*/
fetch(
fetch: (
input: inferProcedureInput<TProcedure>,
opts?: TRPCFetchQueryOptions<
inferTransformedProcedureOutput<TRoot, TProcedure>,
TRPCClientError<TRoot>
>,
): Promise<inferTransformedProcedureOutput<TRoot, TProcedure>>;
) => Promise<inferTransformedProcedureOutput<TRoot, TProcedure>>;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientfetchinfinitequery
*/
fetchInfinite(
fetchInfinite: (
input: inferProcedureInput<TProcedure>,
opts?: TRPCFetchInfiniteQueryOptions<
inferProcedureInput<TProcedure>,
inferTransformedProcedureOutput<TRoot, TProcedure>,
TRPCClientError<TRoot>
>,
): Promise<
) => Promise<
InfiniteData<
inferTransformedProcedureOutput<TRoot, TProcedure>,
NonNullable<ExtractCursorType<inferProcedureInput<TProcedure>>> | null
Expand All @@ -73,41 +73,41 @@ type DecorateProcedure<
/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientprefetchquery
*/
prefetch(
prefetch: (
input: inferProcedureInput<TProcedure>,
opts?: TRPCFetchQueryOptions<
inferTransformedProcedureOutput<TRoot, TProcedure>,
TRPCClientError<TRoot>
>,
): Promise<void>;
) => Promise<void>;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientprefetchinfinitequery
*/
prefetchInfinite(
prefetchInfinite: (
input: inferProcedureInput<TProcedure>,
opts?: TRPCFetchInfiniteQueryOptions<
inferProcedureInput<TProcedure>,
inferTransformedProcedureOutput<TRoot, TProcedure>,
TRPCClientError<TRoot>
>,
): Promise<void>;
) => Promise<void>;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientensurequerydata
*/
ensureData(
ensureData: (
input: inferProcedureInput<TProcedure>,
opts?: TRPCFetchQueryOptions<
inferTransformedProcedureOutput<TRoot, TProcedure>,
TRPCClientError<TRoot>
>,
): Promise<inferTransformedProcedureOutput<TRoot, TProcedure>>;
) => Promise<inferTransformedProcedureOutput<TRoot, TProcedure>>;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientinvalidatequeries
*/
invalidate(
invalidate: (
input?: DeepPartial<inferProcedureInput<TProcedure>>,
filters?: Omit<InvalidateQueryFilters, 'predicate'> & {
predicate?: (
Expand All @@ -125,37 +125,37 @@ type DecorateProcedure<
) => boolean;
},
options?: InvalidateOptions,
): Promise<void>;
) => Promise<void>;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientrefetchqueries
*/
refetch(
refetch: (
input?: inferProcedureInput<TProcedure>,
filters?: RefetchQueryFilters,
options?: RefetchOptions,
): Promise<void>;
) => Promise<void>;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientcancelqueries
*/
cancel(
cancel: (
input?: inferProcedureInput<TProcedure>,
options?: CancelOptions,
): Promise<void>;
) => Promise<void>;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientresetqueries
*/
reset(
reset: (
input?: inferProcedureInput<TProcedure>,
options?: ResetOptions,
): Promise<void>;
) => Promise<void>;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetquerydata
*/
setData(
setData: (
/**
* The input of the procedure
*/
Expand All @@ -165,12 +165,12 @@ type DecorateProcedure<
inferTransformedProcedureOutput<TRoot, TProcedure> | undefined
>,
options?: SetDataOptions,
): void;
) => void;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientsetquerydata
*/
setInfiniteData(
setInfiniteData: (
input: inferProcedureInput<TProcedure>,
updater: Updater<
| InfiniteData<
Expand All @@ -185,21 +185,21 @@ type DecorateProcedure<
| undefined
>,
options?: SetDataOptions,
): void;
) => void;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientgetquerydata
*/
getData(
getData: (
input?: inferProcedureInput<TProcedure>,
): inferTransformedProcedureOutput<TRoot, TProcedure> | undefined;
) => inferTransformedProcedureOutput<TRoot, TProcedure> | undefined;

/**
* @link https://tanstack.com/query/v5/docs/reference/QueryClient#queryclientgetquerydata
*/
getInfiniteData(
getInfiniteData: (
input?: inferProcedureInput<TProcedure>,
):
) =>
| InfiniteData<
inferTransformedProcedureOutput<TRoot, TProcedure>,
NonNullable<ExtractCursorType<inferProcedureInput<TProcedure>>> | null
Expand All @@ -217,11 +217,11 @@ type DecorateRouter = {
* @link https://trpc.io/docs/v10/useContext#query-invalidation
* @link https://tanstack.com/query/v5/docs/framework/react/guides/query-invalidation
*/
invalidate(
invalidate: (
input?: undefined,
filters?: InvalidateQueryFilters,
options?: InvalidateOptions,
): Promise<void>;
) => Promise<void>;
};

/**
Expand Down
Expand Up @@ -91,7 +91,7 @@ export type FileUploadHandlerOptions = {
* @param contentType
* @param name
*/
filter?(args: FileUploadHandlerFilterArgs): Promise<boolean> | boolean;
filter?: (args: FileUploadHandlerFilterArgs) => Promise<boolean> | boolean;
};

const defaultFilePathResolver: FileUploadHandlerPathResolver = ({
Expand Down
Expand Up @@ -29,7 +29,7 @@ export type MemoryUploadHandlerOptions = {
* @param mimetype
* @param encoding
*/
filter?(args: MemoryUploadHandlerFilterArgs): Promise<boolean> | boolean;
filter?: (args: MemoryUploadHandlerFilterArgs) => Promise<boolean> | boolean;
};

export function createMemoryUploadHandler({
Expand Down
Expand Up @@ -59,7 +59,7 @@ export type MemoryUploadHandlerOptions = {
* @param mimetype
* @param encoding
*/
filter?(args: MemoryUploadHandlerFilterArgs): Promise<boolean> | boolean;
filter?: (args: MemoryUploadHandlerFilterArgs) => Promise<boolean> | boolean;
};

/**
Expand Down
12 changes: 6 additions & 6 deletions packages/server/src/observable/operators.test.ts
Expand Up @@ -7,20 +7,20 @@ interface SubscriptionEvents<TOutput> {
}

declare interface CustomEventEmitter<TOutput> {
on<U extends keyof SubscriptionEvents<TOutput>>(
on: <U extends keyof SubscriptionEvents<TOutput>>(
event: U,
listener: SubscriptionEvents<TOutput>[U],
): this;
) => this;

once<U extends keyof SubscriptionEvents<TOutput>>(
once: <U extends keyof SubscriptionEvents<TOutput>>(
event: U,
listener: SubscriptionEvents<TOutput>[U],
): this;
) => this;

emit<U extends keyof SubscriptionEvents<TOutput>>(
emit: <U extends keyof SubscriptionEvents<TOutput>>(
event: U,
...args: Parameters<SubscriptionEvents<TOutput>[U]>
): boolean;
) => boolean;
}
class CustomEventEmitter<TOutput>
extends EventEmitter
Expand Down

0 comments on commit 8f2a0a7

Please sign in to comment.