trash
trash
Explore posts from servers
TTCTheo's Typesafe Cult
Created by trash on 6/10/2023 in #questions
how do i prisma
and didnt need connect
16 replies
TTCTheo's Typesafe Cult
Created by trash on 6/10/2023 in #questions
how do i prisma
all my original code was fine
16 replies
TTCTheo's Typesafe Cult
Created by trash on 6/10/2023 in #questions
how do i prisma
yeah.. the problem was fixed after i blew and recreated node_modules...smh
16 replies
TTCTheo's Typesafe Cult
Created by trash on 6/10/2023 in #questions
how do i prisma
nm i had to delete node modules ......
16 replies
TTCTheo's Typesafe Cult
Created by trash on 6/10/2023 in #questions
how do i prisma
hmm no dice, ill report back. looks like post 2.1 you shouldnt have to write connect based on the docs
16 replies
TTCTheo's Typesafe Cult
Created by trash on 6/10/2023 in #questions
how do i prisma
thanks all.
16 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
thinkies me reading andarists replies
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
ive been nerd sniped so hard
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
that.. has to be a bug right?
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
but that seems .. kinda whack
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
i made a simpler version of this and asked in matts discord.. and noticed that small fix... im gonna cry
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
if you remove that type annotation it breaks.......
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
updated code snippet to arrows pointing
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
if you dont put request: Request inference brakes LOL
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
ok this as eating me alive and it turns out it was a lot simpler
declare function auth(request: Request): { userId: number };

type Config<T> = {
middleware(request: Request): Promise<T>
onUpload(response: {
metadata: T;
file: any;
}): void;
};

export declare function Helper<T extends Record<string, unknown>>(
input: { [K in keyof T]: Config<T[K]> },
): void;

export const SomeFunc = Helper({
someKey: {
middleware: async (request: Request) => { // <------ YOU HAVE TO ANNOTATE REQUEST
const user = await auth(request);

return { userIds: user.userId };
},
onUpload: async (response) => {
console.log(response.metadata);
// ^?

},
}
});
declare function auth(request: Request): { userId: number };

type Config<T> = {
middleware(request: Request): Promise<T>
onUpload(response: {
metadata: T;
file: any;
}): void;
};

export declare function Helper<T extends Record<string, unknown>>(
input: { [K in keyof T]: Config<T[K]> },
): void;

export const SomeFunc = Helper({
someKey: {
middleware: async (request: Request) => { // <------ YOU HAVE TO ANNOTATE REQUEST
const user = await auth(request);

return { userIds: user.userId };
},
onUpload: async (response) => {
console.log(response.metadata);
// ^?

},
}
});
https://tsplay.dev/mL8dVm cc @theo
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
probably worth actually saying gof means gang of four
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
yeah i don’t think template literal type is smart enough or rather evaluates lazily shrug
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
heck yeah
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
162 replies
TTCTheo's Typesafe Cult
Created by theo (t3.gg) on 4/16/2023 in #questions
Mapped Types Not Inferring From Promise Correctly
yeah so you can make something that accounts for like 0 - {yourLimit}
type OneThroughNine = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
type Limit = `${OneThroughNine}${OneThroughNine}`

const x: Limit = ``
type OneThroughNine = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
type Limit = `${OneThroughNine}${OneThroughNine}`

const x: Limit = ``
162 replies