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