I've been searching extensively without luck in finding a solution to this specific issue I'm facing. Any assistance would be greatly appreciated.
Currently, I am implementing closures for simple dependency injection and attempting to avoid functions being passed with the "any" type.
Let's consider the following scenario:
// db-fns.ts
export const makeQuerySql = ({pool: SqlPool}) =>
<T>(query: string, args?: any): Promise<T> => {
// function code
}
// user-fns.ts
export const makeGetUser = ({querySql}: Dependencies) => (userId: number) => {
// function code
}
export interface Dependencies {
querySql: ????
}
// index.ts
import {makeQuerySql} from 'db-fns.ts';
import {makeGetUser} from 'user-fns.ts';
const querySql = makeQuerySql({pool});
const getUser = makeGetUser({querySql});
I'm struggling to determine how to define the typeof querySql within the dependencies interface in user-fns.ts