Rank 3: Container
Hello,
I'm starting to learn Svelte and wanted to connect my little demo app with Appwrite. I saw the todo Svelte demo and was taking some of the logic in that demo but came across the error Argument of type 'User<Preferences>' is not assignable to parameter of type 'null | undefined'. at the state.init(user); line. also getting Type 'Alert' is not assignable to type 'null' on the other line i have marked.
Not am I only new to Svelte but also typescript. Any ideas??
import { get, writable } from 'svelte/store';import { sdk, server } from './appwrite';
export type Alert = { color: string; message: string; };
const createState = () => { const { subscribe, set, update } = writable({ account: null, alert: null, }); return { subscribe, signup: async (email: string, password: string, name: string) => { return await sdk.account.create('unique()', email, password, name); }, login: async (email: string, password: string) => { await sdk.account.createEmailSession(email, password); const user = await sdk.account.get(); -----> state.init(user); }, logout: async () => { await sdk.account.deleteSession('current'); }, alert: async (alert: Alert) => update((n) => { ------> n.alert = alert; return n; }), init: async (account = null) => { return set({ account, alert: null }); }, }; };
export const state = createState();```