I have a small function called firstOrNull:
import { propOr } from 'ramda'
export const firstOrNull = propOr(null, '0')
Now, I want to use this function with a property that returns
QueryDocumentSnapshot<DocumentData>[]
const organization = firstOrNull(snapshot.docs)?.data() as Organization
However, due to the lack of typing on firstOrNull
, I encountered this error:
Object is of type 'unknown'
How can I add correct typing to firstOrNull
?
https://i.sstatic.net/LPaUu.png
Perhaps I need to change it to something like this:
export const firstOrNull:<T[]> = propOr<null, T, number>(null, 0)