UNPKG

cypress

Version:

Cypress is a next generation front end testing tool built for the modern web

1,051 lines (1,018 loc) 248 kB
// tslint:disable:jsdoc-format // tslint:disable:max-line-length // tslint:disable:no-irregular-whitespace declare namespace JQuery { type TypeOrArray<T> = T | T[]; type Node = Element | Text | Comment | DocumentFragment; /** * A string is designated htmlString in jQuery documentation when it is used to represent one or more DOM elements, typically to be created and inserted in the document. When passed as an argument of the jQuery() function, the string is identified as HTML if it starts with <tag ... >) and is parsed as such until the final > character. Prior to jQuery 1.9, a string was considered to be HTML if it contained <tag ... > anywhere within the string. */ type htmlString = string; /** * A selector is used in jQuery to select DOM elements from a DOM document. That document is, in most cases, the DOM document present in all browsers, but can also be an XML document received via Ajax. */ type Selector = string; /** * The PlainObject type is a JavaScript object containing zero or more key-value pairs. The plain object is, in other words, an Object object. It is designated "plain" in jQuery documentation to distinguish it from other kinds of JavaScript objects: for example, null, user-defined arrays, and host objects such as document, all of which have a typeof value of "object." * * **Note**: The type declaration of PlainObject is imprecise. It includes host objects and user-defined arrays which do not match jQuery's definition. */ interface PlainObject<T = any> { [key: string]: T; } interface Selectors extends Sizzle.Selectors { /** * @deprecated ​ Deprecated since 3.0. Use \`{@link Selectors#pseudos }\`. * * **Cause**: The standard way to add new custom selectors through jQuery is `jQuery.expr.pseudos`. These two other aliases are deprecated, although they still work as of jQuery 3.0. * * **Solution**: Rename any of the older usage to `jQuery.expr.pseudos`. The functionality is identical. */ ':': Sizzle.Selectors.PseudoFunctions; /** * @deprecated ​ Deprecated since 3.0. Use \`{@link Selectors#pseudos }\`. * * **Cause**: The standard way to add new custom selectors through jQuery is `jQuery.expr.pseudos`. These two other aliases are deprecated, although they still work as of jQuery 3.0. * * **Solution**: Rename any of the older usage to `jQuery.expr.pseudos`. The functionality is identical. */ filter: Sizzle.Selectors.FilterFunctions; } // region Ajax // #region Ajax interface AjaxSettings<TContext = any> extends Ajax.AjaxSettingsBase<TContext> { /** * A string containing the URL to which the request is sent. */ url?: string; } interface UrlAjaxSettings<TContext = any> extends Ajax.AjaxSettingsBase<TContext> { /** * A string containing the URL to which the request is sent. */ url: string; } namespace Ajax { type SuccessTextStatus = 'success' | 'notmodified' | 'nocontent'; type ErrorTextStatus = 'timeout' | 'error' | 'abort' | 'parsererror'; type TextStatus = SuccessTextStatus | ErrorTextStatus; type SuccessCallback<TContext> = (this: TContext, data: any, textStatus: SuccessTextStatus, jqXHR: jqXHR) => void; type ErrorCallback<TContext> = (this: TContext, jqXHR: jqXHR, textStatus: ErrorTextStatus, errorThrown: string) => void; type CompleteCallback<TContext> = (this: TContext, jqXHR: jqXHR, textStatus: TextStatus) => void; /** * @see \`{@link https://api.jquery.com/jquery.ajax/#jQuery-ajax-settings }\` */ interface AjaxSettingsBase<TContext> { /** * A set of key/value pairs that map a given dataType to its MIME type, which gets sent in the Accept request header. This header tells the server what kind of response it will accept in return. */ accepts?: PlainObject<string>; /** * By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done(). */ async?: boolean; /** * A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request. */ beforeSend?(this: TContext, jqXHR: jqXHR, settings: this): false | void; /** * If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET. */ cache?: boolean; /** * A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request ("success", "notmodified", "nocontent", "error", "timeout", "abort", or "parsererror"). As of jQuery 1.5, the complete setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. */ complete?: TypeOrArray<CompleteCallback<TContext>>; /** * An object of string/regular-expression pairs that determine how jQuery will parse the response, given its content type. */ contents?: PlainObject<RegExp>; /** * When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). As of jQuery 1.6 you can pass false to tell jQuery to not set any content type header. Note: The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding. Note: For cross-domain requests, setting the content type to anything other than application/x-www-form-urlencoded, multipart/form-data, or text/plain will trigger the browser to send a preflight OPTIONS request to the server. */ contentType?: string | false; /** * This object will be the context of all Ajax-related callbacks. By default, the context is an object that represents the Ajax settings used in the call ($.ajaxSettings merged with the settings passed to $.ajax). */ context?: TContext; /** * An object containing dataType-to-dataType converters. Each converter's value is a function that returns the transformed value of the response. */ converters?: PlainObject<((value: any) => any) | true>; /** * If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain. */ crossDomain?: boolean; /** * Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below). */ data?: PlainObject | string; /** * A function to be used to handle the raw response data of XMLHttpRequest. This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter. */ dataFilter?(data: string, type: string): any; /** * The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). The available types (and the result passed as the first argument to your success callback) are: * * "xml": Returns a XML document that can be processed via jQuery. * * "html": Returns HTML as plain text; included script tags are evaluated when inserted in the DOM. * * "script": Evaluates the response as JavaScript and returns it as plain text. Disables caching by appending a query string parameter, _=[TIMESTAMP], to the URL unless the cache option is set to true. Note: This will turn POSTs into GETs for remote-domain requests. * * "json": Evaluates the response as JSON and returns a JavaScript object. Cross-domain "json" requests are converted to "jsonp" unless the request includes jsonp: false in its request options. The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. As of jQuery 1.9, an empty response is also rejected; the server should return a response of null or {} instead. (See json.org for more information on proper JSON formatting.) * * "jsonp": Loads in a JSON block using JSONP. Adds an extra "?callback=?" to the end of your URL to specify the callback. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the cache option is set to true. * * "text": A plain text string. * * multiple, space-separated values: As of jQuery 1.5, jQuery can convert a dataType from what it received in the Content-Type header to what you require. For example, if you want a text response to be treated as XML, use "text xml" for the dataType. You can also make a JSONP request, have it received as text, and interpreted by jQuery as XML: "jsonp text xml". Similarly, a shorthand string such as "jsonp xml" will first attempt to convert from jsonp to xml, and, failing that, convert from jsonp to text, and then from text to xml. */ dataType?: 'xml' | 'html' | 'script' | 'json' | 'jsonp' | 'text' | string; /** * A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event. */ error?: TypeOrArray<ErrorCallback<TContext>>; /** * Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events. */ global?: boolean; /** * An object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport. The header X-Requested-With: XMLHttpRequest is always added, but its default XMLHttpRequest value can be changed here. Values in the headers setting can also be overwritten from within the beforeSend function. */ headers?: PlainObject<string | null | undefined>; /** * Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is false, ignoring the header. In jQuery 1.4 this technique also checks the 'etag' specified by the server to catch unmodified data. */ ifModified?: boolean; /** * Allow the current environment to be recognized as "local," (e.g. the filesystem), even if jQuery does not recognize it as such by default. The following protocols are currently recognized as local: file, *-extension, and widget. If the isLocal setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. */ isLocal?: boolean; /** * Override the callback function name in a JSONP request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So {jsonp:'onJSONPLoad'} would result in 'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the jsonp option to false prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the jsonpCallback setting. For example, { jsonp: false, jsonpCallback: "callbackName" }. If you don't trust the target of your Ajax requests, consider setting the jsonp property to false for security reasons. */ jsonp?: string | false; /** * Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function. */ jsonpCallback?: string | ((this: TContext) => string); /** * The HTTP method to use for the request (e.g. "POST", "GET", "PUT"). */ method?: string; /** * A mime type to override the XHR mime type. */ mimeType?: string; /** * A password to be used with XMLHttpRequest in response to an HTTP access authentication request. */ password?: string; /** * By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false. */ processData?: boolean; /** * Only applies when the "script" transport is used (e.g., cross-domain requests with "jsonp" or "script" dataType and "GET" type). Sets the charset attribute on the script tag used in the request. Used when the character set on the local page is not the same as the one on the remote script. */ scriptCharset?: string; /** * An object of numeric HTTP codes and functions to be called when the response has the corresponding code. * * If the request is successful, the status code functions take the same parameters as the success callback; if it results in an error (including 3xx redirect), they take the same parameters as the error callback. */ statusCode?: StatusCodeCallbacks<TContext>; /** * A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter or the dataFilter callback function, if specified; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event. */ success?: TypeOrArray<SuccessCallback<TContext>>; /** * Set a timeout (in milliseconds) for the request. A value of 0 means there will be no timeout. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period. */ timeout?: number; /** * Set this to true if you wish to use the traditional style of param serialization. */ traditional?: boolean; /** * An alias for method. You should use type if you're using versions of jQuery prior to 1.9.0. */ type?: string; /** * A username to be used with XMLHttpRequest in response to an HTTP access authentication request. */ username?: string; // ActiveXObject requires "lib": ["scripthost"] which consumers would also require /** * Callback for creating the XMLHttpRequest object. Defaults to the ActiveXObject when available (IE), the XMLHttpRequest otherwise. Override to provide your own implementation for XMLHttpRequest or enhancements to the factory. */ xhr?(): XMLHttpRequest; /** * An object of fieldName-fieldValue pairs to set on the native XHR object. * * In jQuery 1.5, the withCredentials property was not propagated to the native XHR and thus CORS requests requiring it would ignore this flag. For this reason, we recommend using jQuery 1.5.1+ should you require the use of it. */ xhrFields?: XHRFields; } // region StatusCodeCallbacks // #region StatusCodeCallbacks type StatusCodeCallbacks<TContext> = { // region Success Status Codes // #region Success Status Codes // jQuery treats 2xx and 304 status codes as a success 200?: SuccessCallback<TContext>; 201?: SuccessCallback<TContext>; 202?: SuccessCallback<TContext>; 203?: SuccessCallback<TContext>; 204?: SuccessCallback<TContext>; 205?: SuccessCallback<TContext>; 206?: SuccessCallback<TContext>; 207?: SuccessCallback<TContext>; 208?: SuccessCallback<TContext>; 209?: SuccessCallback<TContext>; 210?: SuccessCallback<TContext>; 211?: SuccessCallback<TContext>; 212?: SuccessCallback<TContext>; 213?: SuccessCallback<TContext>; 214?: SuccessCallback<TContext>; 215?: SuccessCallback<TContext>; 216?: SuccessCallback<TContext>; 217?: SuccessCallback<TContext>; 218?: SuccessCallback<TContext>; 219?: SuccessCallback<TContext>; 220?: SuccessCallback<TContext>; 221?: SuccessCallback<TContext>; 222?: SuccessCallback<TContext>; 223?: SuccessCallback<TContext>; 224?: SuccessCallback<TContext>; 225?: SuccessCallback<TContext>; 226?: SuccessCallback<TContext>; 227?: SuccessCallback<TContext>; 228?: SuccessCallback<TContext>; 229?: SuccessCallback<TContext>; 230?: SuccessCallback<TContext>; 231?: SuccessCallback<TContext>; 232?: SuccessCallback<TContext>; 233?: SuccessCallback<TContext>; 234?: SuccessCallback<TContext>; 235?: SuccessCallback<TContext>; 236?: SuccessCallback<TContext>; 237?: SuccessCallback<TContext>; 238?: SuccessCallback<TContext>; 239?: SuccessCallback<TContext>; 240?: SuccessCallback<TContext>; 241?: SuccessCallback<TContext>; 242?: SuccessCallback<TContext>; 243?: SuccessCallback<TContext>; 244?: SuccessCallback<TContext>; 245?: SuccessCallback<TContext>; 246?: SuccessCallback<TContext>; 247?: SuccessCallback<TContext>; 248?: SuccessCallback<TContext>; 249?: SuccessCallback<TContext>; 250?: SuccessCallback<TContext>; 251?: SuccessCallback<TContext>; 252?: SuccessCallback<TContext>; 253?: SuccessCallback<TContext>; 254?: SuccessCallback<TContext>; 255?: SuccessCallback<TContext>; 256?: SuccessCallback<TContext>; 257?: SuccessCallback<TContext>; 258?: SuccessCallback<TContext>; 259?: SuccessCallback<TContext>; 260?: SuccessCallback<TContext>; 261?: SuccessCallback<TContext>; 262?: SuccessCallback<TContext>; 263?: SuccessCallback<TContext>; 264?: SuccessCallback<TContext>; 265?: SuccessCallback<TContext>; 266?: SuccessCallback<TContext>; 267?: SuccessCallback<TContext>; 268?: SuccessCallback<TContext>; 269?: SuccessCallback<TContext>; 270?: SuccessCallback<TContext>; 271?: SuccessCallback<TContext>; 272?: SuccessCallback<TContext>; 273?: SuccessCallback<TContext>; 274?: SuccessCallback<TContext>; 275?: SuccessCallback<TContext>; 276?: SuccessCallback<TContext>; 277?: SuccessCallback<TContext>; 278?: SuccessCallback<TContext>; 279?: SuccessCallback<TContext>; 280?: SuccessCallback<TContext>; 281?: SuccessCallback<TContext>; 282?: SuccessCallback<TContext>; 283?: SuccessCallback<TContext>; 284?: SuccessCallback<TContext>; 285?: SuccessCallback<TContext>; 286?: SuccessCallback<TContext>; 287?: SuccessCallback<TContext>; 288?: SuccessCallback<TContext>; 289?: SuccessCallback<TContext>; 290?: SuccessCallback<TContext>; 291?: SuccessCallback<TContext>; 292?: SuccessCallback<TContext>; 293?: SuccessCallback<TContext>; 294?: SuccessCallback<TContext>; 295?: SuccessCallback<TContext>; 296?: SuccessCallback<TContext>; 297?: SuccessCallback<TContext>; 298?: SuccessCallback<TContext>; 299?: SuccessCallback<TContext>; 304?: SuccessCallback<TContext>; // #endregion // region Error Status Codes // #region Error Status Codes 300?: ErrorCallback<TContext>; 301?: ErrorCallback<TContext>; 302?: ErrorCallback<TContext>; 303?: ErrorCallback<TContext>; 305?: ErrorCallback<TContext>; 306?: ErrorCallback<TContext>; 307?: ErrorCallback<TContext>; 308?: ErrorCallback<TContext>; 309?: ErrorCallback<TContext>; 310?: ErrorCallback<TContext>; 311?: ErrorCallback<TContext>; 312?: ErrorCallback<TContext>; 313?: ErrorCallback<TContext>; 314?: ErrorCallback<TContext>; 315?: ErrorCallback<TContext>; 316?: ErrorCallback<TContext>; 317?: ErrorCallback<TContext>; 318?: ErrorCallback<TContext>; 319?: ErrorCallback<TContext>; 320?: ErrorCallback<TContext>; 321?: ErrorCallback<TContext>; 322?: ErrorCallback<TContext>; 323?: ErrorCallback<TContext>; 324?: ErrorCallback<TContext>; 325?: ErrorCallback<TContext>; 326?: ErrorCallback<TContext>; 327?: ErrorCallback<TContext>; 328?: ErrorCallback<TContext>; 329?: ErrorCallback<TContext>; 330?: ErrorCallback<TContext>; 331?: ErrorCallback<TContext>; 332?: ErrorCallback<TContext>; 333?: ErrorCallback<TContext>; 334?: ErrorCallback<TContext>; 335?: ErrorCallback<TContext>; 336?: ErrorCallback<TContext>; 337?: ErrorCallback<TContext>; 338?: ErrorCallback<TContext>; 339?: ErrorCallback<TContext>; 340?: ErrorCallback<TContext>; 341?: ErrorCallback<TContext>; 342?: ErrorCallback<TContext>; 343?: ErrorCallback<TContext>; 344?: ErrorCallback<TContext>; 345?: ErrorCallback<TContext>; 346?: ErrorCallback<TContext>; 347?: ErrorCallback<TContext>; 348?: ErrorCallback<TContext>; 349?: ErrorCallback<TContext>; 350?: ErrorCallback<TContext>; 351?: ErrorCallback<TContext>; 352?: ErrorCallback<TContext>; 353?: ErrorCallback<TContext>; 354?: ErrorCallback<TContext>; 355?: ErrorCallback<TContext>; 356?: ErrorCallback<TContext>; 357?: ErrorCallback<TContext>; 358?: ErrorCallback<TContext>; 359?: ErrorCallback<TContext>; 360?: ErrorCallback<TContext>; 361?: ErrorCallback<TContext>; 362?: ErrorCallback<TContext>; 363?: ErrorCallback<TContext>; 364?: ErrorCallback<TContext>; 365?: ErrorCallback<TContext>; 366?: ErrorCallback<TContext>; 367?: ErrorCallback<TContext>; 368?: ErrorCallback<TContext>; 369?: ErrorCallback<TContext>; 370?: ErrorCallback<TContext>; 371?: ErrorCallback<TContext>; 372?: ErrorCallback<TContext>; 373?: ErrorCallback<TContext>; 374?: ErrorCallback<TContext>; 375?: ErrorCallback<TContext>; 376?: ErrorCallback<TContext>; 377?: ErrorCallback<TContext>; 378?: ErrorCallback<TContext>; 379?: ErrorCallback<TContext>; 380?: ErrorCallback<TContext>; 381?: ErrorCallback<TContext>; 382?: ErrorCallback<TContext>; 383?: ErrorCallback<TContext>; 384?: ErrorCallback<TContext>; 385?: ErrorCallback<TContext>; 386?: ErrorCallback<TContext>; 387?: ErrorCallback<TContext>; 388?: ErrorCallback<TContext>; 389?: ErrorCallback<TContext>; 390?: ErrorCallback<TContext>; 391?: ErrorCallback<TContext>; 392?: ErrorCallback<TContext>; 393?: ErrorCallback<TContext>; 394?: ErrorCallback<TContext>; 395?: ErrorCallback<TContext>; 396?: ErrorCallback<TContext>; 397?: ErrorCallback<TContext>; 398?: ErrorCallback<TContext>; 399?: ErrorCallback<TContext>; 400?: ErrorCallback<TContext>; 401?: ErrorCallback<TContext>; 402?: ErrorCallback<TContext>; 403?: ErrorCallback<TContext>; 404?: ErrorCallback<TContext>; 405?: ErrorCallback<TContext>; 406?: ErrorCallback<TContext>; 407?: ErrorCallback<TContext>; 408?: ErrorCallback<TContext>; 409?: ErrorCallback<TContext>; 410?: ErrorCallback<TContext>; 411?: ErrorCallback<TContext>; 412?: ErrorCallback<TContext>; 413?: ErrorCallback<TContext>; 414?: ErrorCallback<TContext>; 415?: ErrorCallback<TContext>; 416?: ErrorCallback<TContext>; 417?: ErrorCallback<TContext>; 418?: ErrorCallback<TContext>; 419?: ErrorCallback<TContext>; 420?: ErrorCallback<TContext>; 421?: ErrorCallback<TContext>; 422?: ErrorCallback<TContext>; 423?: ErrorCallback<TContext>; 424?: ErrorCallback<TContext>; 425?: ErrorCallback<TContext>; 426?: ErrorCallback<TContext>; 427?: ErrorCallback<TContext>; 428?: ErrorCallback<TContext>; 429?: ErrorCallback<TContext>; 430?: ErrorCallback<TContext>; 431?: ErrorCallback<TContext>; 432?: ErrorCallback<TContext>; 433?: ErrorCallback<TContext>; 434?: ErrorCallback<TContext>; 435?: ErrorCallback<TContext>; 436?: ErrorCallback<TContext>; 437?: ErrorCallback<TContext>; 438?: ErrorCallback<TContext>; 439?: ErrorCallback<TContext>; 440?: ErrorCallback<TContext>; 441?: ErrorCallback<TContext>; 442?: ErrorCallback<TContext>; 443?: ErrorCallback<TContext>; 444?: ErrorCallback<TContext>; 445?: ErrorCallback<TContext>; 446?: ErrorCallback<TContext>; 447?: ErrorCallback<TContext>; 448?: ErrorCallback<TContext>; 449?: ErrorCallback<TContext>; 450?: ErrorCallback<TContext>; 451?: ErrorCallback<TContext>; 452?: ErrorCallback<TContext>; 453?: ErrorCallback<TContext>; 454?: ErrorCallback<TContext>; 455?: ErrorCallback<TContext>; 456?: ErrorCallback<TContext>; 457?: ErrorCallback<TContext>; 458?: ErrorCallback<TContext>; 459?: ErrorCallback<TContext>; 460?: ErrorCallback<TContext>; 461?: ErrorCallback<TContext>; 462?: ErrorCallback<TContext>; 463?: ErrorCallback<TContext>; 464?: ErrorCallback<TContext>; 465?: ErrorCallback<TContext>; 466?: ErrorCallback<TContext>; 467?: ErrorCallback<TContext>; 468?: ErrorCallback<TContext>; 469?: ErrorCallback<TContext>; 470?: ErrorCallback<TContext>; 471?: ErrorCallback<TContext>; 472?: ErrorCallback<TContext>; 473?: ErrorCallback<TContext>; 474?: ErrorCallback<TContext>; 475?: ErrorCallback<TContext>; 476?: ErrorCallback<TContext>; 477?: ErrorCallback<TContext>; 478?: ErrorCallback<TContext>; 479?: ErrorCallback<TContext>; 480?: ErrorCallback<TContext>; 481?: ErrorCallback<TContext>; 482?: ErrorCallback<TContext>; 483?: ErrorCallback<TContext>; 484?: ErrorCallback<TContext>; 485?: ErrorCallback<TContext>; 486?: ErrorCallback<TContext>; 487?: ErrorCallback<TContext>; 488?: ErrorCallback<TContext>; 489?: ErrorCallback<TContext>; 490?: ErrorCallback<TContext>; 491?: ErrorCallback<TContext>; 492?: ErrorCallback<TContext>; 493?: ErrorCallback<TContext>; 494?: ErrorCallback<TContext>; 495?: ErrorCallback<TContext>; 496?: ErrorCallback<TContext>; 497?: ErrorCallback<TContext>; 498?: ErrorCallback<TContext>; 499?: ErrorCallback<TContext>; 500?: ErrorCallback<TContext>; 501?: ErrorCallback<TContext>; 502?: ErrorCallback<TContext>; 503?: ErrorCallback<TContext>; 504?: ErrorCallback<TContext>; 505?: ErrorCallback<TContext>; 506?: ErrorCallback<TContext>; 507?: ErrorCallback<TContext>; 508?: ErrorCallback<TContext>; 509?: ErrorCallback<TContext>; 510?: ErrorCallback<TContext>; 511?: ErrorCallback<TContext>; 512?: ErrorCallback<TContext>; 513?: ErrorCallback<TContext>; 514?: ErrorCallback<TContext>; 515?: ErrorCallback<TContext>; 516?: ErrorCallback<TContext>; 517?: ErrorCallback<TContext>; 518?: ErrorCallback<TContext>; 519?: ErrorCallback<TContext>; 520?: ErrorCallback<TContext>; 521?: ErrorCallback<TContext>; 522?: ErrorCallback<TContext>; 523?: ErrorCallback<TContext>; 524?: ErrorCallback<TContext>; 525?: ErrorCallback<TContext>; 526?: ErrorCallback<TContext>; 527?: ErrorCallback<TContext>; 528?: ErrorCallback<TContext>; 529?: ErrorCallback<TContext>; 530?: ErrorCallback<TContext>; 531?: ErrorCallback<TContext>; 532?: ErrorCallback<TContext>; 533?: ErrorCallback<TContext>; 534?: ErrorCallback<TContext>; 535?: ErrorCallback<TContext>; 536?: ErrorCallback<TContext>; 537?: ErrorCallback<TContext>; 538?: ErrorCallback<TContext>; 539?: ErrorCallback<TContext>; 540?: ErrorCallback<TContext>; 541?: ErrorCallback<TContext>; 542?: ErrorCallback<TContext>; 543?: ErrorCallback<TContext>; 544?: ErrorCallback<TContext>; 545?: ErrorCallback<TContext>; 546?: ErrorCallback<TContext>; 547?: ErrorCallback<TContext>; 548?: ErrorCallback<TContext>; 549?: ErrorCallback<TContext>; 550?: ErrorCallback<TContext>; 551?: ErrorCallback<TContext>; 552?: ErrorCallback<TContext>; 553?: ErrorCallback<TContext>; 554?: ErrorCallback<TContext>; 555?: ErrorCallback<TContext>; 556?: ErrorCallback<TContext>; 557?: ErrorCallback<TContext>; 558?: ErrorCallback<TContext>; 559?: ErrorCallback<TContext>; 560?: ErrorCallback<TContext>; 561?: ErrorCallback<TContext>; 562?: ErrorCallback<TContext>; 563?: ErrorCallback<TContext>; 564?: ErrorCallback<TContext>; 565?: ErrorCallback<TContext>; 566?: ErrorCallback<TContext>; 567?: ErrorCallback<TContext>; 568?: ErrorCallback<TContext>; 569?: ErrorCallback<TContext>; 570?: ErrorCallback<TContext>; 571?: ErrorCallback<TContext>; 572?: ErrorCallback<TContext>; 573?: ErrorCallback<TContext>; 574?: ErrorCallback<TContext>; 575?: ErrorCallback<TContext>; 576?: ErrorCallback<TContext>; 577?: ErrorCallback<TContext>; 578?: ErrorCallback<TContext>; 579?: ErrorCallback<TContext>; 580?: ErrorCallback<TContext>; 581?: ErrorCallback<TContext>; 582?: ErrorCallback<TContext>; 583?: ErrorCallback<TContext>; 584?: ErrorCallback<TContext>; 585?: ErrorCallback<TContext>; 586?: ErrorCallback<TContext>; 587?: ErrorCallback<TContext>; 588?: ErrorCallback<TContext>; 589?: ErrorCallback<TContext>; 590?: ErrorCallback<TContext>; 591?: ErrorCallback<TContext>; 592?: ErrorCallback<TContext>; 593?: ErrorCallback<TContext>; 594?: ErrorCallback<TContext>; 595?: ErrorCallback<TContext>; 596?: ErrorCallback<TContext>; 597?: ErrorCallback<TContext>; 598?: ErrorCallback<TContext>; 599?: ErrorCallback<TContext>; // #endregion } & { // Status codes not listed require type annotations when defining the callback [index: number]: SuccessCallback<TContext> | ErrorCallback<TContext>; }; // #endregion // Writable properties on XMLHttpRequest interface XHRFields extends Partial<Pick<XMLHttpRequest, 'onreadystatechange' | 'responseType' | 'timeout' | 'withCredentials'>> { msCaching?: string; } } interface Transport { send(headers: PlainObject, completeCallback: Transport.SuccessCallback): void; abort(): void; } namespace Transport { type SuccessCallback = (status: number, statusText: Ajax.TextStatus, responses?: PlainObject, headers?: string) => void; } /** * @see \`{@link https://api.jquery.com/jquery.ajax/#jqXHR }\` */ interface jqXHR<TResolve = any> extends Promise3<TResolve, jqXHR<TResolve>, never, Ajax.SuccessTextStatus, Ajax.ErrorTextStatus, never, jqXHR<TResolve>, string, never>, Pick<XMLHttpRequest, 'abort' | 'getAllResponseHeaders' | 'getResponseHeader' | 'overrideMimeType' | 'readyState' | 'responseText' | 'setRequestHeader' | 'status' | 'statusText'>, Partial<Pick<XMLHttpRequest, 'responseXML'>> { responseJSON?: any; abort(statusText?: string): void; /** * Determine the current state of a Deferred object. * @see \`{@link https://api.jquery.com/deferred.state/ }\` * @since 1.7 */ state(): 'pending' | 'resolved' | 'rejected'; statusCode(map: Ajax.StatusCodeCallbacks<any>): void; } namespace jqXHR { interface DoneCallback<TResolve = any, TjqXHR = jqXHR<TResolve>> extends Deferred.Callback3<TResolve, Ajax.SuccessTextStatus, TjqXHR> { } interface FailCallback<TjqXHR> extends Deferred.Callback3<TjqXHR, Ajax.ErrorTextStatus, string> { } interface AlwaysCallback<TResolve = any, TjqXHR = jqXHR<TResolve>> extends Deferred.Callback3<TResolve | TjqXHR, Ajax.TextStatus, TjqXHR | string> { } } // #endregion // region Callbacks // #region Callbacks interface CallbacksStatic { /** * A multi-purpose callbacks list object that provides a powerful way to manage callback lists. * @param flags An optional list of space-separated flags that change how the callback list behaves. * @see \`{@link https://api.jquery.com/jQuery.Callbacks/ }\` * @since 1.7 */ // tslint:disable-next-line:ban-types callable-types no-unnecessary-generics <T extends Function>(flags?: string): Callbacks<T>; } // tslint:disable-next-line:ban-types interface Callbacks<T extends Function = Function> { /** * Add a callback or a collection of callbacks to a callback list. * @param callback A function, or array of functions, that are to be added to the callback list. * @param callbacks A function, or array of functions, that are to be added to the callback list. * @see \`{@link https://api.jquery.com/callbacks.add/ }\` * @since 1.7 * @example ​ ````Use callbacks.add() to add new callbacks to a callback list: ```javascript // A sample logging function to be added to a callbacks list var foo = function( value ) { console.log( "foo: " + value ); }; ​ // Another function to also be added to the list var bar = function( value ) { console.log( "bar: " + value ); }; ​ var callbacks = $.Callbacks(); ​ // Add the function "foo" to the list callbacks.add( foo ); ​ // Fire the items on the list callbacks.fire( "hello" ); // Outputs: "foo: hello" ​ // Add the function "bar" to the list callbacks.add( bar ); ​ // Fire the items on the list again callbacks.fire( "world" ); ​ // Outputs: // "foo: world" // "bar: world" ``` */ add(callback: TypeOrArray<T>, ...callbacks: Array<TypeOrArray<T>>): this; /** * Disable a callback list from doing anything more. * @see \`{@link https://api.jquery.com/callbacks.disable/ }\` * @since 1.7 * @example ​ ````Use callbacks.disable() to disable further calls to a callback list: ```javascript // A sample logging function to be added to a callbacks list var foo = function( value ) { console.log( value ); }; ​ var callbacks = $.Callbacks(); ​ // Add the above function to the list callbacks.add( foo ); ​ // Fire the items on the list callbacks.fire( "foo" ); // Outputs: foo ​ // Disable further calls being possible callbacks.disable(); ​ // Attempt to fire with "foobar" as an argument callbacks.fire( "foobar" ); // foobar isn't output ``` */ disable(): this; /** * Determine if the callbacks list has been disabled. * @see \`{@link https://api.jquery.com/callbacks.disabled/ }\` * @since 1.7 * @example ​ ````Use callbacks.disabled() to determine if the callbacks list has been disabled: ```javascript // A sample logging function to be added to a callbacks list var foo = function( value ) { console.log( "foo:" + value ); }; ​ var callbacks = $.Callbacks(); ​ // Add the logging function to the callback list callbacks.add( foo ); ​ // Fire the items on the list, passing an argument callbacks.fire( "hello" ); // Outputs "foo: hello" ​ // Disable the callbacks list callbacks.disable(); ​ // Test the disabled state of the list console.log ( callbacks.disabled() ); // Outputs: true ``` */ disabled(): boolean; /** * Remove all of the callbacks from a list. * @see \`{@link https://api.jquery.com/callbacks.empty/ }\` * @since 1.7 * @example ​ ````Use callbacks.empty() to empty a list of callbacks: ```javascript // A sample logging function to be added to a callbacks list var foo = function( value1, value2 ) { console.log( "foo: " + value1 + "," + value2 ); }; ​ // Another function to also be added to the list var bar = function( value1, value2 ) { console.log( "bar: " + value1 + "," + value2 ); }; ​ var callbacks = $.Callbacks(); ​ // Add the two functions callbacks.add( foo ); callbacks.add( bar ); ​ // Empty the callbacks list callbacks.empty(); ​ // Check to ensure all callbacks have been removed console.log( callbacks.has( foo ) ); // false console.log( callbacks.has( bar ) ); // false ``` */ empty(): this; /** * Call all of the callbacks with the given arguments. * @param args The argument or list of arguments to pass back to the callback list. * @see \`{@link https://api.jquery.com/callbacks.fire/ }\` * @since 1.7 * @example ​ ````Use callbacks.fire() to invoke the callbacks in a list with any arguments that have been passed: ```javascript // A sample logging function to be added to a callbacks list var foo = function( value ) { console.log( "foo:" + value ); }; ​ var callbacks = $.Callbacks(); ​ // Add the function "foo" to the list callbacks.add( foo ); ​ // Fire the items on the list callbacks.fire( "hello" ); // Outputs: "foo: hello" callbacks.fire( "world" ); // Outputs: "foo: world" ​ // Add another function to the list var bar = function( value ){ console.log( "bar:" + value ); }; ​ // Add this function to the list callbacks.add( bar ); ​ // Fire the items on the list again callbacks.fire( "hello again" ); // Outputs: // "foo: hello again" // "bar: hello again" ``` */ fire(...args: any[]): this; /** * Determine if the callbacks have already been called at least once. * @see \`{@link https://api.jquery.com/callbacks.fired/ }\` * @since 1.7 * @example ​ ````Use callbacks.fired() to determine if the callbacks in a list have been called at least once: ```javascript // A sample logging function to be added to a callbacks list var foo = function( value ) { console.log( "foo:" + value ); }; ​ var callbacks = $.Callbacks(); ​ // Add the function "foo" to the list callbacks.add( foo ); ​ // Fire the items on the list callbacks.fire( "hello" ); // Outputs: "foo: hello" callbacks.fire( "world" ); // Outputs: "foo: world" ​ // Test to establish if the callbacks have been called console.log( callbacks.fired() ); ``` */ fired(): boolean; /** * Call all callbacks in a list with the given context and arguments. * @param context A reference to the context in which the callbacks in the list should be fired. * @param args An argument, or array of arguments, to pass to the callbacks in the list. * @see \`{@link https://api.jquery.com/callbacks.fireWith/ }\` * @since 1.7 * @example ​ ````Use callbacks.fireWith() to fire a list of callbacks with a specific context and an array of arguments: ```javascript // A sample logging function to be added to a callbacks list var log = function( value1, value2 ) { console.log( "Received: " + value1 + "," + value2 ); }; ​ var callbacks = $.Callbacks(); ​ // Add the log method to the callbacks list callbacks.add( log ); ​ // Fire the callbacks on the list using the context "window" // and an arguments array ​ callbacks.fireWith( window, [ "foo","bar" ] ); // Outputs: "Received: foo, bar" ``` */ fireWith(context: object, args?: ArrayLike<any>): this; /** * Determine whether or not the list has any callbacks attached. If a callback is provided as an argument, determine whether it is in a list. * @param callback The callback to search for. * @see \`{@link https://api.jquery.com/callbacks.has/ }\` * @since 1.7 * @example ​ ````Use callbacks.has() to check if a callback list contains a specific callback: ```javascript // A sample logging function to be added to a callbacks list var foo = function( value1, value2 ) { console.log( "Received: " + value1 + "," + value2 ); }; ​ // A second function which will not be added to the list var bar = function( value1, value2 ) { console.log( "foobar" ); }; ​ var callbacks = $.Callbacks(); ​ // Add the log method to the callbacks list callbacks.add( foo ); ​ // Determine which callbacks are in the list console.log( callbacks.has( foo ) ); // true console.log( callbacks.has( bar ) ); // false ``` */ has(callback?: T): boolean; /** * Lock a callback list in its current state. * @see \`{@link https://api.jquery.com/callbacks.lock/ }\` * @since 1.7 * @example ​ ````Use callbacks.lock() to lock a callback list to avoid further changes being made to the list state: ```javascript // A sample logging function to be added to a callbacks list var foo = function( value ) { console.log( "foo:" + value ); }; ​ var callbacks = $.Callbacks(); ​ // Add the logging function to the callback list callbacks.add( foo ); ​ // Fire the items on the list, passing an argument callbacks.fire( "hello" ); // Outputs "foo: hello" ​ // Lock the callbacks list callbacks.lock(); ​ // Try firing the items again callbacks.fire( "world" ); ​ // As the list was locked, no items were called, // so "world" isn't logged ``` * @example ​ ````Use callbacks.lock() to lock a callback list with &quot;memory,&quot; and then resume using the list: ```html <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>callbacks.lock demo</title> <script src="https://code.jquery.com/jquery-3.3.1.js"></script> </head> <body> ​ <div id="log"></div> ​ <script> // Simple function for logging results var log = function( value ) { $( "#log" ).append( "<p>" + value + "</p>" ); }; ​ // Two sample functions to be added to a callbacks list var foo = function( value ) { log( "foo: " + value ); }; var bar = function( value ) { log( "bar: " + value ); }; ​ // Create the callbacks object with the "memory" flag var callbacks = $.Callbacks( "memory" ); ​ // Add the foo logging function to the callback list callbacks.add( foo ); ​ // Fire the items on the list, passing an argument callbacks.fire( "hello" ); // Outputs "foo: hello" ​ // Lock the callbacks list callbacks.lock(); ​ // Try firing the items again callbacks.fire( "world" ); // As the list was locked, no items were called, // so "foo: world" isn't logged ​ // Add the foo function to the callback list again callbacks.add( foo ); ​ // Try firing the items again callbacks.fire( "silentArgument" ); // Outputs "foo: hello" because the argument value was stored in memory ​ // Add the bar function to the callback list callbacks.add( bar ); ​ callbacks.fire( "youHadMeAtHello" ); // Outputs "bar: hello" because the list is still locked, // and the ar