joken-前端工程师

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::

代码

  • global.d.ts global中声明全局类型
    image
declare global {
  /**
   * 响应数据
   */
  interface ResponseData<T = any> {
    code: string;
    data: T;
    msg: string;
  }

}
//加入export 就可以使global中的全局类型声明生效,项目中使用就不会报错了
export {};


type MyObject<T = any> = Record<string, T>;

或者加入import也可以
image

  • 全局使用
    image

参考文章

https://blog.csdn.net/Haveyounow/article/details/138136661
https://blog.csdn.net/qq_41887214/article/details/137589276

posted on 2024-07-10 21:38  joken1310  阅读(4)  评论(0编辑  收藏  举报