I have this method:
export default class ApiService {
static makeApiCall = (
url: string,
normalizeCallback: (d: ResponseData) => ResponseData | null,
callback: (d: any) => any
): Promise<void> => (
ApiClient.get(url)
.then(res => {
callback(normalizeCallback(res.data));
})
.catch(error => {
console.error(`ApiClient ${url}`, error);
})
)
static getArticles = (callback: (a: Article[]) => void): Promise<void> => (
ApiService.makeApiCall(
'articles',
ApiNormalizer.normalizeArticles,
callback
)
)
}
On this line callback: (d: any) => any typescript yells
warning Unexpected any. Specify a different type
To show you more context, here is where I am calling the method getArticles
export const fetchArticles = (): ThunkAction<Promise<void>,{},{},AnyAction> => {
return async (dispatch: ThunkDispatch<{}, {}, AnyAction>): Promise<void> => {
dispatch(() => ({ type: FETCH_ARTICLES }));
// HERE: getArticles
return ApiService.getArticles(articles => dispatch(loadArticles(articles)));
};
};
So how can i type that callback function properly?