Skip to content

Rename LoadInput to LoadEvent #4965

@felixsanz

Description

@felixsanz

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

NA

Severity

serious, but I can work around it

Additional Information

NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions