1. 1 : /* eslint-disable @typescript-eslint/triple-slash-reference */
  2. 2 : /* eslint-disable @typescript-eslint/ban-types */
  3. 3 : /// <reference types="jquery" />
  4. 4 : /// <reference lib="dom" />
  5. 5 :
  6. 6 : /**
  7. 7 : * Custom global
  8. 8 : */
  9. 9 : interface CustomNodeJsGlobal extends NodeJS.Global {
  10. 10 : [key: string]: any;
  11. 11 : }
  12. 12 : // Tell Typescript to use this type on the globally scoped `global` variable.
  13. 13 : declare const global: CustomNodeJsGlobal;
  14. 14 :
  15. 15 : /**
  16. 16 : * Creates a new function.
  17. 17 : */
  18. 18 : interface Function {
  19. 19 : /**
  20. 20 : * Run function once
  21. 21 : * @example
  22. 22 : * (()=> console.log).once('hello'); // run console.log('hello') once
  23. 23 : */
  24. 24 : once: (param?: anyOf) => any;
  25. 25 : /**
  26. 26 : * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.
  27. 27 : * @param thisArg The object to be used as the this object.
  28. 28 : * @param argArray A set of arguments to be passed to the function.
  29. 29 : */
  30. 30 : apply(this: Function, thisArg: any, argArray?: any): any;
  31. 31 :
  32. 32 : /**
  33. 33 : * Calls a method of an object, substituting another object for the current object.
  34. 34 : * @param thisArg The object to be used as the current object.
  35. 35 : * @param argArray A list of arguments to be passed to the method.
  36. 36 : */
  37. 37 : call(this: Function, thisArg: any, ...argArray: any[]): any;
  38. 38 :
  39. 39 : /**
  40. 40 : * For a given function, creates a bound function that has the same body as the original function.
  41. 41 : * The this object of the bound function is associated with the specified object, and has the specified initial parameters.
  42. 42 : * @param thisArg An object to which the this keyword can refer inside the new function.
  43. 43 : * @param argArray A list of arguments to be passed to the new function.
  44. 44 : */
  45. 45 : bind(this: Function, thisArg: any, ...argArray: any[]): any;
  46. 46 :
  47. 47 : /** Returns a string representation of a function. */
  48. 48 : toString(): string;
  49. 49 :
  50. 50 : prototype: any;
  51. 51 : readonly length: number;
  52. 52 :
  53. 53 : // Non-standard extensions
  54. 54 : arguments: any;
  55. 55 : caller: Function;
  56. 56 : }
  57. 57 :
  58. 58 : //declare const $: JQuery;
  59. 59 :
  60. 60 : type jQuery = JQuery;
  61. 61 :
  62. 62 : interface XMLHttpRequest extends XMLHttpRequestEventTarget {
  63. 63 : responseJSON: Array<any> | Record<string, unknown> | null;
  64. 64 : }
  65. 65 :
  66. 66 : interface EventTarget {
  67. 67 : matches(pattern: string): boolean;
  68. 68 : }
  69. 69 :
  70. 70 : /**
  71. 71 : * HTML element
  72. 72 : */
  73. 73 : interface HTMLScriptElement extends HTMLElement {
  74. 74 : async: boolean;
  75. 75 :
  76. 76 : onreadystatechange(): void;
  77. 77 : }
  78. 78 :
  79. 79 : interface HTMLElement
  80. 80 : extends Element,
  81. 81 : DocumentAndElementEventHandlers,
  82. 82 : ElementCSSInlineStyle,
  83. 83 : ElementContentEditable,
  84. 84 : GlobalEventHandlers,
  85. 85 : HTMLOrSVGElement {
  86. 86 : mozMatchesSelector: (selectors: string) => boolean;
  87. 87 : msMatchesSelector: (selectors: string) => boolean;
  88. 88 :
  89. 89 : [attachEvent: string]: any;
  90. 90 : }
  91. 91 :
  92. 92 : /**
  93. 93 : * Create element options
  94. 94 : */
  95. 95 : interface createElementOpt {
  96. 96 : childs: any[];
  97. 97 : /**
  98. 98 : * Tag name to be created
  99. 99 : */
  100. 100 : tagName: string;
  101. 101 : /**
  102. 102 : * Add classname
  103. 103 : */
  104. 104 : className: string;
  105. 105 : /**
  106. 106 : * Some attributes ?
  107. 107 : */
  108. 108 : attributes: { attributes: { [str: string]: any } };
  109. 109 : /**
  110. 110 : * InnerText ?
  111. 111 : */
  112. 112 : text: string;
  113. 113 : /**
  114. 114 : * InnerHTML ?
  115. 115 : */
  116. 116 : html: string;
  117. 117 : /**
  118. 118 : * Some options
  119. 119 : */
  120. 120 : options: { attributes: any[]; childs: [] };
  121. 121 : }
  122. 122 :
  123. 123 : /**
  124. 124 : * Create element helper
  125. 125 : * * if you use without tagName you will get a document fragment
  126. 126 : * @example
  127. 127 : * document.body.appendChild(createElement({
  128. 128 : tagName: "div",
  129. 129 : className: "my-class",
  130. 130 : text: "Blah blah",
  131. 131 : attributes: {
  132. 132 : "id": "element id",
  133. 133 : "data-truc": "value"
  134. 134 : },
  135. 135 : childs: [{ `recursif call` }]
  136. 136 : }))
  137. 137 : */
  138. 138 : declare function createElement(params: createElementOpt);
  139. 139 :
  140. 140 : /**
  141. 141 : * String start
  142. 142 : */
  143. 143 :
  144. 144 : /**
  145. 145 : * Window Start
  146. 146 : */
  147. 147 : // Add IE-specific interfaces to Window
  148. 148 : interface Window {
  149. 149 : HTMLElement: HTMLElement;
  150. 150 : //user: user;
  151. 151 : /**
  152. 152 : * Opera navigator
  153. 153 : */
  154. 154 : readonly opera: string;
  155. 155 : dataLayer: [];
  156. 156 : mozRTCPeerConnection: any;
  157. 157 :
  158. 158 : attachEvent(event: string, listener: EventListener): boolean;
  159. 159 :
  160. 160 : detachEvent(event: string, listener: EventListener): void;
  161. 161 :
  162. 162 : [func: string]: any;
  163. 163 :
  164. 164 : gtag(message?: any, ...optionalParams: any[]): void;
  165. 165 : }
  166. 166 :
  167. 167 : interface Document
  168. 168 : extends Node,
  169. 169 : DocumentAndElementEventHandlers,
  170. 170 : DocumentOrShadowRoot,
  171. 171 : GlobalEventHandlers,
  172. 172 : NonElementParentNode,
  173. 173 : ParentNode,
  174. 174 : XPathEvaluatorBase {
  175. 175 : /**
  176. 176 : * window.addEventListener
  177. 177 : *
  178. 178 : * Appends an event listener for events whose type attribute value is type. The callback argument sets the callback
  179. 179 : * that will be invoked when the event is dispatched.
  180. 180 : *
  181. 181 : * The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the
  182. 182 : * method behaves exactly as if the value was specified as options's capture.
  183. 183 : */
  184. 184 : attachEvent: any;
  185. 185 :
  186. 186 : /**
  187. 187 : * @see {@link Document.addEventListener}
  188. 188 : */
  189. 189 : listen<K extends keyof DocumentEventMap>(
  190. 190 : type: K,
  191. 191 : listener: (this: Document, ev: DocumentEventMap[K]) => any,
  192. 192 : options?: boolean | AddEventListenerOptions
  193. 193 : ): void;
  194. 194 : listen(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
  195. 195 : removeListener<K extends keyof DocumentEventMap>(
  196. 196 : type: K,
  197. 197 : listener: (this: Document, ev: DocumentEventMap[K]) => any,
  198. 198 : options?: boolean | EventListenerOptions
  199. 199 : ): void;
  200. 200 : removeListener(
  201. 201 : type: string,
  202. 202 : listener: EventListenerOrEventListenerObject,
  203. 203 : options?: boolean | EventListenerOptions
  204. 204 : ): void;
  205. 205 : }