Skip to content

Commit

Permalink
minimum types for submission flash
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid committed Mar 4, 2024
1 parent 4e9ca33 commit 83e827d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-kids-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/router": patch
---

minimum types for submission flash
11 changes: 8 additions & 3 deletions src/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export const RouterContextObj = createContext<RouterContext>();
export const RouteContextObj = createContext<RouteContext>();

export const useRouter = () =>
invariant(useContext(RouterContextObj), "<A> and 'use' router primitives can be only used inside a Route.");
invariant(
useContext(RouterContextObj),
"<A> and 'use' router primitives can be only used inside a Route."
);

let TempRoute: RouteContext | undefined;
export const useRoute = () => TempRoute || useContext(RouteContextObj) || useRouter().base;
Expand Down Expand Up @@ -270,7 +273,7 @@ export function createRouterContext(
integration: RouterIntegration,
getContext?: () => any,
getBranches?: () => Branch[],
options: { base?: string, singleFlight?: boolean } = {}
options: { base?: string; singleFlight?: boolean } = {}
): RouterContext {
const {
signal: [source, setSource],
Expand Down Expand Up @@ -464,7 +467,9 @@ export function createRouterContext(

function initFromFlash() {
const e = getRequestEvent();
return e && e.router && e.router.submission ? [e.router.submission] : [];
return (e && e.router && e.router.submission
? [e.router.submission]
: []) as Array<Submission<any, any>>;
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ declare module "solid-js/web" {
router? : {
matches?: OutputMatch[];
cache?: Map<string, CacheEntry>;
submission?: Submission<any, any>;
submission?: {
input: any;
result?: any;
url: string;
};
dataOnly?: boolean | string[];
data?: Record<string, any>;
previousUrl?: string;
Expand Down

0 comments on commit 83e827d

Please sign in to comment.