global.d.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // Type definitions for [~THE LIBRARY NAME~] [~OPTIONAL VERSION NUMBER~]
  2. // Project: [~THE PROJECT NAME~]
  3. // Definitions by: [~YOUR NAME~] <[~A URL FOR YOU~]>
  4. // import EditorJS from "@editorjs/editorjs";
  5. /*~ If this library is callable (e.g. can be invoked as myLib(3)),
  6. *~ include those call signatures here.
  7. *~ Otherwise, delete this section.
  8. */
  9. // declare function myLib(a: string): string;
  10. // declare function myLib(a: number): number;
  11. // /*~ If you want the name of this library to be a valid type name,
  12. // *~ you can do so here.
  13. // *~
  14. // *~ For example, this allows us to write 'var x: myLib';
  15. // *~ Be sure this actually makes sense! If it doesn't, just
  16. // *~ delete this declaration and add types inside the namespace below.
  17. // */
  18. // interface myLib {
  19. // name: string;
  20. // length: number;
  21. // extras?: string[];
  22. // }
  23. // interface Window {
  24. // EditorJS: EditorJS;
  25. // }
  26. // TS有用。JS没用。
  27. // interface Window {
  28. // test: string;
  29. // }
  30. // declare var ee: EditorJS;
  31. // JS可用。 window.gee
  32. // declare global {
  33. // var gee: EditorJS;
  34. // // 或者
  35. // interface Window {
  36. // gtest: string;
  37. // }
  38. // }
  39. // /*~ If your library has properties exposed on a global variable,
  40. // *~ place them here.
  41. // *~ You should also place types (interfaces and type alias) here.
  42. // */
  43. // declare namespace myLib {
  44. // //~ We can write 'myLib.timeout = 50;'
  45. // let timeout: number;
  46. // //~ We can access 'myLib.version', but not change it
  47. // const version: string;
  48. // //~ There's some class we can create via 'let c = new myLib.Cat(42)'
  49. // //~ Or reference e.g. 'function f(c: myLib.Cat) { ... }
  50. // class Cat {
  51. // constructor(n: number);
  52. // //~ We can read 'c.age' from a 'Cat' instance
  53. // readonly age: number;
  54. // //~ We can invoke 'c.purr()' from a 'Cat' instance
  55. // purr(): void;
  56. // }
  57. // //~ We can declare a variable as
  58. // //~ 'var s: myLib.CatSettings = { weight: 5, name: "Maru" };'
  59. // interface CatSettings {
  60. // weight: number;
  61. // name: string;
  62. // tailLength?: number;
  63. // }
  64. // //~ We can write 'const v: myLib.VetID = 42;'
  65. // //~ or 'const v: myLib.VetID = "bob";'
  66. // type VetID = string | number;
  67. // //~ We can invoke 'myLib.checkCat(c)' or 'myLib.checkCat(c, v);'
  68. // function checkCat(c: Cat, s?: VetID);
  69. // }
  70. import Vue from "vue";
  71. import { AxiosInstance, AxiosRequestConfig } from "axios";
  72. // 可惜内部代码不能通过此类型推导
  73. //import * as api from "./api";
  74. declare module '*.vue' {
  75. import Vue from 'vue'
  76. export default Vue
  77. }
  78. declare module "vue/types/vue" {
  79. interface Vue {
  80. $http: AxiosInstance;
  81. // $api: api;
  82. /** @param cause "?cause=正常退出" */
  83. logout(cause?: string): Promise;
  84. /**
  85. * 会在 beforeDestory 中自动清除
  86. * @param {function} fn 要执行的函数
  87. * @param {number} interval 执行间隔ms
  88. */
  89. addInterval(fn: Function, interval: number): void;
  90. /**
  91. * 会在 beforeDestory 中自动清除
  92. * @param {function} fn 要执行的函数
  93. * @param {number} interval 执行间隔ms
  94. */
  95. addTimeout(fn: Function, interval: number): void;
  96. }
  97. }
  98. declare module "axios/index" {
  99. interface AxiosRequestConfig {
  100. noErrorMessage?: boolean | false;
  101. }
  102. }