typescript 擴展 window 和 global


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

 

二、前端:

  

declare interface Window {
    FILE_CDN: string;
    FILE_HOST: string;
    API_SERVER: string;
    JAVA_API: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
  }
} 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM