I'm still new to typescript, but I'm trying to pass a custom type to a function. I'm avoiding using "any" for this case, here is my example.
interface ReturnObj<T> {
returnObj: T | null
}
const createResultObj = (
isSuccessful: boolean = false,
returnObj: ReturnObj = null,
errors: AppError | null = null,
statusCode: number = 500
): Result => {
return {
isSuccessful,
returnObj,
errors,
statusCode
}
}
Naturally, this is returning an error with Generic type 'ReturnObj<T>' requires 1 type argument(s).
but I'm not sure how to fill this part in so that I can call in this function and include the type if something exists in the returnObj.