H
Hono3w ago
h

Argument type string is not assignable to parameter type keyof E["Variables"]

I'm using Hono with Webstorm and whenever I use .get() or .set() with some key of string, webstorm will always complain such type mismatch. Even the type-safe guard on docs doesn't help. The code: https://github.com/search?q=repo%3Aminhperry%2Fcf-worker-backend%20c.get(&type=code
No description
5 Replies
h
h3w ago
It still does work, just that webstorm is complaining. Maybe is this its problem instead of Hono's?
Aditya Mathur
Aditya Mathur3w ago
make your context type like this
Context<{
Variables: {
user: unknown // Add whatever type you want
}
}>
Context<{
Variables: {
user: unknown // Add whatever type you want
}
}>
h
h2d ago
still complains idk
No description
Aditya Mathur
Aditya Mathur17h ago
Seems to be working on VSCode -
export const getUserField = (
context: Context<{ Variables: { user: string } }>
) => {
const user = context.get("user");
};
export const getUserField = (
context: Context<{ Variables: { user: string } }>
) => {
const user = context.get("user");
};
Aditya Mathur
Aditya Mathur17h ago
No description
Want results from more Discord servers?
Add your server