鉴于以下代码,我收到数据常量的不安全分配错误。
import { useQuery, QueryResult } from "react-query";
import { url } from './api';
import { User, UserFetch } from '../types/User';
const getUser = async (): Promise<User> => {
//
// Unsafe assignment of an any value.eslint@typescript-eslint/no-unsafe-assignment
//
const data = await fetch(url).then((res) => res.json());
return data;
}
export default function useUser(): QueryResult<User> {
return useQuery<User>("userData", getUser);
}
如何安全地键入数据分配的等待结果?