Skip to content

Commit 83e827d

Browse files
committedMar 4, 2024
minimum types for submission flash
1 parent 4e9ca33 commit 83e827d

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed
 

‎.changeset/brown-kids-dance.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@solidjs/router": patch
3+
---
4+
5+
minimum types for submission flash

‎src/routing.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ export const RouterContextObj = createContext<RouterContext>();
5353
export const RouteContextObj = createContext<RouteContext>();
5454

5555
export const useRouter = () =>
56-
invariant(useContext(RouterContextObj), "<A> and 'use' router primitives can be only used inside a Route.");
56+
invariant(
57+
useContext(RouterContextObj),
58+
"<A> and 'use' router primitives can be only used inside a Route."
59+
);
5760

5861
let TempRoute: RouteContext | undefined;
5962
export const useRoute = () => TempRoute || useContext(RouteContextObj) || useRouter().base;
@@ -270,7 +273,7 @@ export function createRouterContext(
270273
integration: RouterIntegration,
271274
getContext?: () => any,
272275
getBranches?: () => Branch[],
273-
options: { base?: string, singleFlight?: boolean } = {}
276+
options: { base?: string; singleFlight?: boolean } = {}
274277
): RouterContext {
275278
const {
276279
signal: [source, setSource],
@@ -464,7 +467,9 @@ export function createRouterContext(
464467

465468
function initFromFlash() {
466469
const e = getRequestEvent();
467-
return e && e.router && e.router.submission ? [e.router.submission] : [];
470+
return (e && e.router && e.router.submission
471+
? [e.router.submission]
472+
: []) as Array<Submission<any, any>>;
468473
}
469474
}
470475

‎src/types.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ declare module "solid-js/web" {
1010
router? : {
1111
matches?: OutputMatch[];
1212
cache?: Map<string, CacheEntry>;
13-
submission?: Submission<any, any>;
13+
submission?: {
14+
input: any;
15+
result?: any;
16+
url: string;
17+
};
1418
dataOnly?: boolean | string[];
1519
data?: Record<string, any>;
1620
previousUrl?: string;

0 commit comments

Comments
 (0)
Please sign in to comment.