I'm in the process of converting one of my React Firebase project to typescript with help of react-redux-firebase documentation. One of the problem I'm having is how to correctly define types for the fireabase and firestore functions. For example, here's my React reducer action function.
import { Dispatch } from "redux";
import { PROJECT_TYPES } from "../../action-types/project";
import { PROJECT_ACTION } from "../../action/project";
import { IPROJECT } from "../../interface/project";
export const createProject = (project: IPROJECT) => async (dispatch:Dispatch<PROJECT_ACTION>, getState:any, { getFirebase, getFirestore }:any):Promise<void> => {
const firestore = getFirestore();
firestore.collection('projects').add({
...project,
authorFirstName: getState().firebase.profile.firstName,
authorLastName:getState().firebase.profile.lastName,
authorId:getState().firebase.auth.uid,
createdAt:new Date()
}).then(() => {
dispatch({
type: PROJECT_TYPES.CREATE_PROJECT,
payload: project
})
}).catch((err:any) => {
console.log({err})
dispatch({ type: PROJECT_TYPES.CREATE_PROJECT_ERROR, payload: err })
})
}
As see above code I've defined the type as any to the getState, getFirebase and getFirestore functions. I'm not happy with that type, so I want to know is there a correct way to define these types?
Instructions followed from the http://react-redux-firebase.com/docs/api/getFirebase.html link
Thanks in advance.