代码改变世界

typescript 扩展 window 和 global

2021-07-09 18:30  muamaker  阅读(3284)  评论(0编辑  收藏  举报

一、都是新建一个 custom.d.ts

 

二、前端:

  

declare interface Window {
    FILE_CDN: string;
    FILE_HOST: string;
    API_SERVER: string;
    JAVA_API:string;

}



declare global {
    interface Window {
        FILE_CDN: string;
    
    }
  }

  

三、node 里面

declare namespace NodeJS {
    export interface Global {
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      logger: any;
    }
}

 

四 、扩展 axios

import { AxiosRequestConfig } from 'axios'

declare module 'axios' {

  export interface AxiosRequestConfig {
    loading?: boolean
  }
}