I am messing around with modules in my typescript react project. Trying to get them to work. I declared my async function in my .ts file with types as so here:
//Library Imports
//Firestore SDK
import {
getFirestore,
collection,
getDocs,
setDoc,
doc,
addDoc,
getDoc,
} from "firebase/firestore/lite";
//Firestore Config module
import { fireApp } from "./FirestoreConfig";
const fireData = getFirestore(fireApp);
//Get all documents from collection
const getAllDocs = async (Collection: string): Promise<any[]> => {
let baseQuery = await getDocs(collection(fireData, Collection));
let docs: any[] = [];
baseQuery.forEach((doc) => docs.push(doc.data()));
return docs;
};
export { getAllDocs };
I then import "getAllDocs" in my react app.tsx and I'm getting the error
So I'm trying to use a d.ts file to define the type of my function, and I can't get it working. my d.ts file looks like this. This doesn't fix the issue.
declare module "getAllDocs" {
export default function getAllDocs(Collection: string): Promise<any[]>;
}
How do I properly type the function to remove the error? I don't want to ignore the error. The d.ts file is in the exact same directory as the module I am trying to export. Any help would be greatly appreciated.