Alan
TTCTheo's Typesafe Cult
•Created by Alan on 6/5/2023 in #questions
Exhaustive Switch in TypeScript
Hello, I am currently writing a little backend code with TypeScript, and I want to use some exhaustive switch to give back my client proper errors.
However, the types are not work as what I expected, can someone help me?
TS Playground: https://tsplay.dev/w29YrW
I don't understand why both
result1
on line 25 and result2
on line 42 are of type ErrorResult
but behaves differently when I switch on them.
How can I handle the errors properly?
Should I manually type the secondService
so that it returns ErrorResult<"not permitted" | "not found">
?7 replies
TTCTheo's Typesafe Cult
•Created by Alan on 6/1/2023 in #questions
Android emulator cannot connect to my Expo without tunnel
Hello, I am building an app with
create-t3-turbo
in windows 11.
I keep getting the error connection timed out from the Expo Go in the emulator.
I've tried to turn off my firewall, set the REACT_NATIVE_PACKAGER_HOSTNAME
environment variable, but all of these do not solve the issue.
However, when I use the tunnel mode to open my app, it just works without all of the configurations.
How can I solve the issue, or how can I setup the function getBaseUrl
in tunnel mode when initializing tRPC client to make my Expo app connect to my tRPC endpoints?2 replies
TTCTheo's Typesafe Cult
•Created by Alan on 1/30/2023 in #questions
NextAuth: Cannot login with CredentialsProvider
I'm currently developing my web app using the full-featured t3 app, and I don't want to connect to the real provider while developing.
(Since there are roles and it's much better if I can switch my role during development directly on my UI)
According to the answer of the following GitHub issue and a side note from t3-app docs, I added a credential provider in the
authOptions
object inside src/api/auth/[...nextauth].ts
with some hardcoded users.
https://github.com/nextauthjs/next-auth/issues/5587
But now I found that after the login succeeded, it refreshed my page and my app just kept being in the not logged-in state.
(The next-auth.session-token
cookies does appear, but gone after the refresh)
Am I doing anything wrong? How could I fix this?
1 replies