Cách mở rộng interface Options trong axios-hooks một ví dụ quá hay (ok)

Module này chỉ có 4 thuộc tính manual, useCache, ssr, autoCancel câu hỏi đặt ra giờ tôi muốn thêm thuộc tính initialData thì phải làm sao?

Giải quyết vấn đề

next-env.d.ts

/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
interface Post {
  id: number;
  title: string;
  body: string;
}
import 'axios-hooks';
declare module 'axios-hooks' {
  export interface Options {
    initialData?: Post[]; // Thêm thuộc tính mới
  }
}

Last updated