-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
The endpoint's get function doesn't have type for input arguments. In javascript you can use the generated types, but that's not possible with typescript. So the whole object or individual keys should be able to type. Example:
export async function get({ params }: ThereIsNoTypeAvailable): Promise<RequestHandlerOutput> {}export async function get({ params }: { params: ThereIsNoTypeAvailable }): Promise<RequestHandlerOutput> {}The output is fine, RequestHandlerOutput is available and we can use it.
Yeah, you can type a function expression like this:
export const get: RequestHandler = async ({ params }) => {}But it's impossible to type function statements right now. There's RequestEvent but it's not exported (it's private).
On the other hand, the load function is fine:
export async function load({ params, fetch }: LoadInput): Promise<LoadOutput> {}You can use the Load type on a function expression or LoadInput + LoadOutput on a function statement.
So we should have consistency and have both input and output types available in functions, specially get.
| load() | get() |
|---|---|
| Load | RequestHandler |
| LoadInput | ???????? |
| LoadOutput | RequestHandlerOutput |
Maybe RequestHandlerInput ?
Reproduction
NA
Logs
No response
System Info
NASeverity
serious, but I can work around it
Additional Information
NA