写在前面
在 TypeScript
项目中,TypeScript
对接口返回数据的处理,是日常项目开发中一个比较棘手的问题。
我们该如何 高效 的解决这个问题?
问题
项目中使用 ts
都会碰到如下场景?
const fetchInfo = async (url: string, id: string) => {
return $http.get(url, params);
}
const res = await fetchInfo('/info', '886');
// 假设 `/info` 接口返回如下数据
{ id: '886',