0
votes

SignIn.svelte:

import { auth, userDoc } from '$lib/db/firebase';
import { signInWithEmailAndPassword } from 'firebase/auth';
import { setDoc } from 'firebase/firestore/lite';

let email: string;
let password: string;

async function signIn() {
    try {
        let { user } = await signInWithEmailAndPassword(auth, email, password);
        await setDoc(userDoc(auth.currentUser.uid), { email: user.email });
        await goto('/notes');
    } catch (e) {
        console.log('Error sign in', e.message);
    }
}

firebase.ts

const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);

const userDoc = (userId: string) => doc(db, 'users', userId);

export { auth, userDoc };

Typescript shows error in userDoc(): Argument type DocumentReference<DocumentData is not assignable to parameter type DocumentReference<email: string>.

Console logs this: "FirebaseError: Expected type 'wn', but it was: a custom ba2 object"

I just want to pass object with email field but I can't.

Thanks for help