I am using ag-grid with React and would like to use useDynamicCallback function. However, the given example is a js one and I would like to use it in typescript.
Below is what they have:
function useDynamicCallback(callback) {
const ref = useRef();
ref.current = callback;
return useCallback((...args) => ref.current.apply(this, args), []);
}
Below is how I added types to escape ts-lint errors:
const useDynamicCallback = (callback: any) => {
const ref = useRef();
ref.current = callback;
return useCallback((...args) => (ref as any).current.apply(this, args), []);
};
Can someone help me with a strongly typed function so I can get away with any, if possible? Thanks.

