HonestCode
HonestCode
Explore posts from servers
TTCTheo's Typesafe Cult
Created by HonestCode on 1/1/2024 in #questions
Use process(css).then(cb) to work with async plugins
"nativewind": "^2.0.11", "tailwindcss": "3.3.2", what is wrong here? Everywhere i looked people said to downgrade. I downgraded and it still doesnt work
2 replies
TTCTheo's Typesafe Cult
Created by HonestCode on 5/7/2023 in #questions
modals don't work on create-t3-turbo
1 replies
TTCTheo's Typesafe Cult
Created by HonestCode on 3/31/2023 in #questions
What would be a good practice for writing types for components that get passed a trpc query?
lets say a query looks like this:
const item = await prisma.business.findFirst({
where: { id: input.id },
include: {
business_hours: {
include: {
dayOfWeek: true,
},
},
address: true,
services: true,
socialMedia: true,
businessImages: true,
events: {
include: {
attendees: true,
},
},
eventReservations: {
where: {
status: 'PENDING',
},
select: {
Service: {
include: {
category: true,
},
},
reservationEndDate: true,
date: true,
},
},
},
})
const item = await prisma.business.findFirst({
where: { id: input.id },
include: {
business_hours: {
include: {
dayOfWeek: true,
},
},
address: true,
services: true,
socialMedia: true,
businessImages: true,
events: {
include: {
attendees: true,
},
},
eventReservations: {
where: {
status: 'PENDING',
},
select: {
Service: {
include: {
category: true,
},
},
reservationEndDate: true,
date: true,
},
},
},
})
i call it from root component, and i get my typesafe query, all is cool, but now i need to pass the query somewhere else. for that, i need to specify the type
root.tsx


const profile = trpc.listings.singleListing.useQuery({
id: parseInt(id, 10),
})
...
<Profile profileData={profile.data.items} />
profile.tsx
type Props = {
profileData: what type?
}
root.tsx


const profile = trpc.listings.singleListing.useQuery({
id: parseInt(id, 10),
})
...
<Profile profileData={profile.data.items} />
profile.tsx
type Props = {
profileData: what type?
}
5 replies
TTCTheo's Typesafe Cult
Created by HonestCode on 3/15/2023 in #questions
Is there anything similar to trpc in SvelteKit?
What the title says
4 replies
TTCTheo's Typesafe Cult
Created by HonestCode on 2/12/2023 in #questions
queryClient type errors when adding default options to queryclient
export const TRPCProvider: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const [queryClient] = React.useState(
() =>
new QueryClient({
defaultOptions: { refetchOnWindowFocus: false, staleTime: 120000 },
})
)
const [trpcClient] = React.useState(() =>
api.createClient({
transformer,
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error),
}),
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
}),
],
})
)

return (
<api.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</api.Provider>
)
}
export const TRPCProvider: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const [queryClient] = React.useState(
() =>
new QueryClient({
defaultOptions: { refetchOnWindowFocus: false, staleTime: 120000 },
})
)
const [trpcClient] = React.useState(() =>
api.createClient({
transformer,
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error),
}),
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
}),
],
})
)

return (
<api.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
</api.Provider>
)
}
(property) refetchOnWindowFocus: boolean
Type '{ refetchOnWindowFocus: false; staleTime: number; }' is not assignable to type 'DefaultOptions<unknown>'.
Object literal may only specify known properties, and 'refetchOnWindowFocus' does not exist in type 'DefaultOptions<unknown>'.ts(2322)
(property) refetchOnWindowFocus: boolean
Type '{ refetchOnWindowFocus: false; staleTime: number; }' is not assignable to type 'DefaultOptions<unknown>'.
Object literal may only specify known properties, and 'refetchOnWindowFocus' does not exist in type 'DefaultOptions<unknown>'.ts(2322)
whats up with that?
2 replies
TTCTheo's Typesafe Cult
Created by HonestCode on 1/25/2023 in #questions
create-t3-turbo expo tunnel doesnt fetch on a physical device.
3 replies