diff --git a/package.json b/package.json index 1e047c2..d7600c3 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "scripts": { "build": "npm run build:libs && npm run build:types", "build:libs": "rollup -c", - "build:types": "tsc --declaration --emitDeclarationOnly --outDir types", + "build:types": "rm -r types && tsc --declaration --emitDeclarationOnly --outDir types", "ci": "bun run lint:circular && bun run type-check", "clean": "rm -r es lib dist coverage .eslintcache node_modules/.cache", "lint:circular": "dpdm src/**/*.{ts,tsx} --warning false --tree false --exit-code circular:1 -T true", diff --git a/src/lib/AppWriteProvider.tsx b/src/lib/AppWriteProvider.tsx index dde7d29..3d69466 100644 --- a/src/lib/AppWriteProvider.tsx +++ b/src/lib/AppWriteProvider.tsx @@ -25,7 +25,20 @@ export type AppWriteContextType = { isAuthenticationLoading: boolean; }; -const AppWriteContext = createContext(undefined); +const AppWriteContext = createContext({ + signUp: async () => { + throw new Error('AppWriteProvider not found'); + }, + signIn: async () => { + throw new Error('AppWriteProvider not found'); + }, + signOut: async () => { + throw new Error('AppWriteProvider not found'); + }, + isAuthenticated: false, + user: undefined, + isAuthenticationLoading: true, +}); export const useAppWrite = () => useContext(AppWriteContext); diff --git a/types/lib/AppWriteProvider.d.ts b/types/lib/AppWriteProvider.d.ts index 0201760..bac96cb 100644 --- a/types/lib/AppWriteProvider.d.ts +++ b/types/lib/AppWriteProvider.d.ts @@ -20,5 +20,5 @@ export declare type AppWriteContextType = { user: Models.Document | undefined; isAuthenticationLoading: boolean; }; -export declare const useAppWrite: () => AppWriteContextType | undefined; +export declare const useAppWrite: () => AppWriteContextType; export declare const AppWriteProvider: FC; diff --git a/types/lib/app-write-auth.d.ts b/types/lib/app-write-auth.d.ts index 417c65a..51dd64f 100644 --- a/types/lib/app-write-auth.d.ts +++ b/types/lib/app-write-auth.d.ts @@ -1,8 +1,8 @@ import { type AppwriteConfigType } from './AppWriteProvider'; export declare const appWriteAuth: (config: AppwriteConfigType) => { - signUp: (email: string, password: string, username: string) => Promise; - signIn: (email: string, password: string) => Promise; - getAccount: () => Promise>; - getCurrentUser: () => Promise; + signUp: (email: string, password: string, username: string) => Promise; + signIn: (email: string, password: string) => Promise; + getAccount: () => Promise>; + getCurrentUser: () => Promise; signOut: () => Promise<{}>; };