Skip to content

Strange reference values when using new svelte-persistent-store. #24

@michaelcuneo

Description

@michaelcuneo

I just transitioned an old project to a new version of Svelte, with .TS and all the other upgrades I can think of., and I'm getting unusual references in my localStorage and sessionStorage instead of actual data.

This is my store.ts

import { persist, createLocalStorage, createSessionStorage } from '@macfja/svelte-persistent-store';
import type { PersistentStore } from '@macfja/svelte-persistent-store';
import { writable } from 'svelte/store';

type user = {
  username: string;
};

type error = {
  status: boolean;
  message: string;
};

class CapripolStore {
  constructor(
    public transitionUser: PersistentStore<object> = persist(writable([]), createSessionStorage(), 'transitionUser'),
    public user: PersistentStore<user> = persist(writable(<user>({})), createSessionStorage(), 'user'),
    public mfa: PersistentStore<boolean> = persist(writable(false), createSessionStorage(), 'mfa'),
    public signupConfirm: PersistentStore<boolean> = persist(writable(false), createSessionStorage(), 'signupConfirm'),
    public passwordReset: PersistentStore<boolean> = persist(writable(false), createSessionStorage(), 'passwordReset'),
    public error: PersistentStore<error> = persist(writable(<error>({})), createSessionStorage(), 'error'),
  ) {}
}

export const capripolStore = new CapripolStore();

When I look at the values of everything, transitionUser, user, and error, are all ["#$@__reference__0"]

For some reason, signupConfirm, passwordReset, and mfa are all fine. Not sure what's going on here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingquestionFurther information is requestedversion 2.x

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions