我正在尝试键入getMenu(key)
函数的参数,它最初是一个字符串,但是在迁移到 3.0 之后,它迫使我将键设为一个QueryFunctionContext<any, any>
类型,但我需要一个像以前一样的字符串。有什么想法吗?谢谢!
export const getMenu = async (key: string): Promise<IMenuItemData> => {
try {
const payload = await axios.get(key);
return payload.data;
} catch (reason) {
throw parseError(reason);
}
};
export const useMenu = (slug: string): UseQueryResult<IMenuPayload, IServerErrorObject> => {
return useQuery<IMenuPayload, TError, IMenuPayload>(
`menu/${slug}`,
----------> (key: string): Promise<IMenuPayload> => getMenu(key)
);
};