fix: asResponse return type not correctly inferred on getSession

This commit is contained in:
Bereket Engida
2024-12-08 16:54:36 +03:00
parent b5e7757c3a
commit cddf8b0a82
2 changed files with 9 additions and 7 deletions

View File

@@ -5,7 +5,7 @@ import { getDate } from "../../utils/date";
import { memoryAdapter, type MemoryDB } from "../../adapters/memory-adapter";
describe("session", async () => {
const { client, testUser, sessionSetter, cookieSetter } =
const { client, testUser, sessionSetter, cookieSetter, auth } =
await getTestInstance();
it("should set cookies correctly on sign in", async () => {

View File

@@ -32,16 +32,18 @@ export type InferSessionAPI<API> = API extends {
E extends Endpoint
? E["path"] extends "/get-session"
? {
getSession: ((context: {
getSession: <R extends boolean>(context: {
headers: Headers;
query?: {
disableCookieCache?: boolean;
};
asResponse?: boolean;
}) => Promise<PrettifyDeep<Awaited<ReturnType<E>>>>) & {
options: E["options"];
path: E["path"];
};
asResponse?: R;
}) => R extends true
? Promise<Response>
: Promise<PrettifyDeep<Awaited<ReturnType<E>>>> & {
options: E["options"];
path: E["path"];
};
}
: never
: never