Skip to content

Commit 24b54f1

Browse files
differentiate between input and output params inside Load (#4160)
* differentiate between input and output params inside `Load` * add changeset * run format * update changelog message Co-authored-by: Rich Harris <[email protected]> * use `InputProps` as default value for `OutputProps` Co-authored-by: Rich Harris <[email protected]> * Update .changeset/yellow-geese-tap.md Co-authored-by: Rich Harris <[email protected]> Co-authored-by: Rich Harris <[email protected]>
1 parent 579fa9c commit 24b54f1

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

.changeset/yellow-geese-tap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[breaking] allow `InputProps` and `OutputProps` to be typed separately in `Load`

packages/kit/types/index.d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,14 @@ export interface HandleError {
116116
*
117117
* Note that you can use [generated types](/docs/types#generated-types) instead of manually specifying the Params generic argument.
118118
*/
119-
export interface Load<Params = Record<string, string>, Props = Record<string, any>> {
120-
(input: LoadInput<Params>): MaybePromise<Either<Fallthrough, LoadOutput<Props>>>;
119+
export interface Load<
120+
Params extends Record<string, string> = Record<string, string>,
121+
InputProps extends Record<string, any> = Record<string, any>,
122+
OutputProps extends Record<string, any> = InputProps
123+
> {
124+
(input: LoadInput<Params, InputProps>): MaybePromise<
125+
Either<Fallthrough, LoadOutput<OutputProps>>
126+
>;
121127
}
122128

123129
export interface Navigation {

packages/kit/types/private.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,10 @@ export type JSONValue =
220220
| JSONValue[]
221221
| JSONObject;
222222

223-
export interface LoadInput<Params = Record<string, string>> {
223+
export interface LoadInput<Params = Record<string, string>, Props = Record<string, any>> {
224224
url: URL;
225225
params: Params;
226-
props: Record<string, any>;
226+
props: Props;
227227
fetch(info: RequestInfo, init?: RequestInit): Promise<Response>;
228228
session: App.Session;
229229
stuff: Partial<App.Stuff>;

0 commit comments

Comments
 (0)