Skip to content
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

Feature/R-03 na registreren terug startscherm #199

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
felixcicatt committed Jul 25, 2022
commit 93c37bf6c283cfc5a9069209ad02c68cc159adbd
13 changes: 13 additions & 0 deletions src/stores/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { StoreDefinition } from "pinia";
import type { DeepReadonly } from "vue";

type ReadonlyStoreDefinition<T extends StoreDefinition> =
T extends StoreDefinition<string, infer S, infer G, infer A>
? () => DeepReadonly<S> & G & A
: never;

export function asReadOnly<T extends StoreDefinition>(
storeDefinition: T
): ReadonlyStoreDefinition<T> {
return storeDefinition as unknown as ReadonlyStoreDefinition<T>;
}
4 changes: 2 additions & 2 deletions src/stores/toast.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineStore } from "pinia";
import type { ReadonlyStoreDefinition } from "./types";
import { asReadOnly } from "./helpers";

type MessageType = "confirm" | "error";

Expand Down Expand Up @@ -39,4 +39,4 @@ const useStore = defineStore("toast", {
},
});

export const useToast = useStore as ReadonlyStoreDefinition<typeof useStore>;
export const useToast = asReadOnly(useStore);
7 changes: 0 additions & 7 deletions src/stores/types.ts

This file was deleted.