-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename LoadInput
to LoadEvent
#4965
Comments
I think we should make You can use generated types with TS, though right now you need to add import type { RequestHandler } from './index.d'; That'll be fixed by #4705, once we agree on exactly how it should look. |
I think for consistency it should be LoadInput/LoadOutput and RequestHandlerInput/RequestHandlerOutput. Because the arguments are the function's input. And an event imo is the whole function when it's called. |
You can think of a request handler (either in an endpoint, or the main addEventListener('GET', event => {
// ...
}); The argument to the handler callback is always called The same convention is used inside AWS Lambda: exports.handler = async function(event, context) {
return {...};
}; So |
LoadInput
to LoadEvent
I just merged #4809 which makes |
Then... if this functions (get(), post()... load()) are attached/subscribed like a listener, then Event is appropriate. If they are just called... i don't think so. I'm kinda new and don't know the sveltekit internals, but probably it just boils down to that. |
Making private types public seems to be my purpose in life. Maybe I should branch out to renaming public types... If you'd like to rename |
* rename LoadInput to LoadEvent - closes #4965 * Update packages/kit/types/index.d.ts Co-authored-by: Maurício Kishi <[email protected]> * Update packages/kit/types/index.d.ts Co-authored-by: Maurício Kishi <[email protected]> Co-authored-by: Maurício Kishi <[email protected]>
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:The output is fine,
RequestHandlerOutput
is available and we can use it.Yeah, you can type a function expression like this:
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:You can use the
Load
type on a function expression orLoadInput
+LoadOutput
on a function statement.So we should have consistency and have both input and output types available in functions, specially
get
.Maybe
RequestHandlerInput
?Reproduction
NA
Logs
No response
System Info
Severity
serious, but I can work around it
Additional Information
NA
The text was updated successfully, but these errors were encountered: