We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Would be nice to make paths be type safe to prevent errors.
paths
export const usePlayerStore = defineStore("player", () => { return { keyA: true, keyB: true, keyC: { keyC1: true, }, }; }, { persist: { paths: ["keyA", "keyb"] // oops, keyB is mis-spelled }, });
You can do this today:
type FlattenKeys< T extends Record<string, unknown>, Key = keyof T, > = Key extends string ? T[Key] extends Record<string, unknown> ? `${Key}.${FlattenKeys<T[Key]>}` : `${Key}` : never; type StateKeys = FlattenKeys<ReturnType<typeof storeFn>>; function storeFn() { return { keyA: true, keyB: true, keyC: { keyC1: true, }, }; } export const usePlayerStore = defineStore("player", storeFn, { persist: { paths: ["keyA", "keyb", "keyC.keyC1"] satisfies StateKeys[], // Will complain that `keyb` does not exist }, });
It would be great to have this built-in to Pinia so you wouldn't have to separate the storeFn by it self to be able to get the ReturnType.
ReturnType
No response
The text was updated successfully, but these errors were encountered:
This is planned someday when i get some time, maybe for v4, as i already made a package for it (see https://github.com/prazdevs/deep-pick-omit)
I'm just overworked and can't spend much time onthe project atm.
Sorry, something went wrong.
No worries — thank you for a great plugin! 😊
No branches or pull requests
Clear and concise description of the problem
Would be nice to make
paths
be type safe to prevent errors.Suggested solution
You can do this today:
Alternative
It would be great to have this built-in to Pinia so you wouldn't have to separate the storeFn by it self to be able to get the
ReturnType
.Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: