Skip to content

Commit 6144da8

Browse files
committedJul 8, 2024
fix Response type narrowing in submission APIs
1 parent a64b83d commit 6144da8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
 

‎.changeset/gentle-windows-guess.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/router": patch
3+
---
4+
5+
fix Response type narrowing in submission APIs

‎src/data/action.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const actions = /* #__PURE__ */ new Map<string, Action<any, any>>();
2121
export function useSubmissions<T extends Array<any>, U>(
2222
fn: Action<T, U>,
2323
filter?: (arg: T) => boolean
24-
): Submission<T, U>[] & { pending: boolean } {
24+
): Submission<T, NarrowResponse<U>>[] & { pending: boolean } {
2525
const router = useRouter();
2626
const subs = createMemo(() =>
2727
router.submissions[0]().filter(s => s.url === fn.toString() && (!filter || filter(s.input)))
@@ -38,7 +38,7 @@ export function useSubmissions<T extends Array<any>, U>(
3838
export function useSubmission<T extends Array<any>, U>(
3939
fn: Action<T, U>,
4040
filter?: (arg: T) => boolean
41-
): Submission<T, U> | SubmissionStub {
41+
): Submission<T, NarrowResponse<U>> | SubmissionStub {
4242
const submissions = useSubmissions(fn, filter);
4343
return new Proxy(
4444
{},
@@ -48,7 +48,7 @@ export function useSubmission<T extends Array<any>, U>(
4848
return submissions[submissions.length - 1]?.[property as keyof Submission<T, U>];
4949
}
5050
}
51-
) as Submission<T, U>;
51+
) as Submission<T, NarrowResponse<U>>;
5252
}
5353

5454
export function useAction<T extends Array<any>, U>(action: Action<T, U>) {

0 commit comments

Comments
 (0)
Please sign in to comment.