Inconsistent Type Inference in Context Across Files in Elysia - Seeking Help #784
Unanswered
BeamNawapat
asked this question in
Q&A
Replies: 1 comment
-
I think I’ve identified the problem. It seems that when I add the response type in the ctx, it defaults to any. However, when I remove it, the type is correctly inferred. response: {
200: t.Object({
success: t.Boolean(),
data: t.Object({}),
}),
other: t.Object({
success: t.Boolean({
default: false,
}),
message: t.String({}),
statusCode: t.Number({
example: 401,
}),
details: t.Object({}),
}),
}, but in my code about the response when it success return new Response(
JSON.stringify({
success: true,
data: {},
}),
{
headers: { "Content-Type": "application/json" },
}
); when it fails it will |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello Everyone,
I’m trying to ensure that the Context in my route handlers has all the necessary derived and decorated properties, properly typed across different files. However, I’ve encountered an issue where in some files, the Context type is correctly inferred, while in others, it isn’t.
I’m also planning to set 'strict' to false in my tsconfig.json to potentially address some of these issues. If there are any additional configurations or methods I should consider to ensure consistent type derivation and decoration in Context across all files, I’d greatly appreciate your advice.
Example
customer.ts
logs.ts
Beta Was this translation helpful? Give feedback.
All reactions