Skip to content

Commit e32c23c

Browse files
authored
🤖 Merge PR DefinitelyTyped#74367 [jquery] Updated types to version 4.0.0 by @DreierF
1 parent f0e9e60 commit e32c23c

33 files changed

+44551
-536
lines changed

types/jquery/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
!**/*.d.*.ts
66
/v1/
77
/v2/
8+
/v3/

types/jquery/JQuery.d.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12225,18 +12225,6 @@ $( "a" ).on( "click", function( event ) {
1222512225
| ((this: TElement, index: number, className: string, state: TState) => string),
1222612226
state?: TState,
1222712227
): this;
12228-
/**
12229-
* Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.
12230-
* @param state A boolean value to determine whether the class should be added or removed.
12231-
* @see \`{@link https://api.jquery.com/toggleClass/ }\`
12232-
* @since 1.4
12233-
* @deprecated ​ Deprecated since 3.0. See \`{@link https://github.com/jquery/jquery/pull/2618 }\`.
12234-
*
12235-
* **Cause**: Calling `.toggleClass()` with no arguments, or with a single Boolean `true` or `false` argument, has been deprecated. Its behavior was poorly documented, but essentially the method saved away the current class value in a data item when the class was removed and restored the saved value when it was toggled back. If you do not believe you are specificially trying to use this form of the method, it is possible you are accidentally doing so via an inadvertent undefined value, as `.toggleClass( undefined )` toggles all classes.
12236-
*
12237-
* **Solution**: If this functionality is still needed, save the current full `.attr( "class" )` value in a data item and restore it when required.
12238-
*/
12239-
toggleClass(state?: boolean): this;
1224012228
/**
1224112229
* Execute all handlers and behaviors attached to the matched elements for the given event type.
1224212230
* @param eventType_event _@param_ `eventType_event`

types/jquery/JQueryStatic.d.ts

Lines changed: 0 additions & 273 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ interface JQueryStatic {
1515
* @since 1.4.3
1616
*/
1717
cssHooks: JQuery.CSSHooks;
18-
/**
19-
* An object containing all CSS properties that may be used without a unit. The .css() method uses this object to see if it may append px to unitless values.
20-
* @see \`{@link https://api.jquery.com/jQuery.cssNumber/ }\`
21-
* @since 1.4.3
22-
*/
23-
cssNumber: JQuery.PlainObject<boolean>;
2418
Deferred: JQuery.DeferredStatic;
2519
easing: JQuery.Easings;
2620
Event: JQuery.EventStatic;
@@ -354,10 +348,6 @@ $.ajax({ data: myData });
354348
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
355349
) => JQuery.Transport | void,
356350
): void;
357-
/**
358-
* @deprecated ​ Deprecated since 3.3. Internal. See \`{@link https://github.com/jquery/jquery/issues/3384 }\`.
359-
*/
360-
camelCase(value: string): string;
361351
cleanData(elems: ArrayLike<Element | Document | Window | JQuery.PlainObject>): void;
362352
/**
363353
* Check to see if a DOM element is a descendant of another DOM element.
@@ -2039,34 +2029,6 @@ $spans.eq( 3 ).text( jQuery.inArray( "Pete", arr, 2 ) );
20392029
```
20402030
*/
20412031
inArray<T>(value: T, array: T[], fromIndex?: number): number;
2042-
/**
2043-
* Determine whether the argument is an array.
2044-
* @param obj Object to test whether or not it is an array.
2045-
* @see \`{@link https://api.jquery.com/jQuery.isArray/ }\`
2046-
* @since 1.3
2047-
* @deprecated ​ Deprecated since 3.2. Use \`{@link ArrayConstructor.isArray Array.isArray}\`.
2048-
* @example ​ ````Finds out if the parameter is an array.
2049-
```html
2050-
<!doctype html>
2051-
<html lang="en">
2052-
<head>
2053-
<meta charset="utf-8">
2054-
<title>jQuery.isArray demo</title>
2055-
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
2056-
</head>
2057-
<body>
2058-
2059-
Is [] an Array? <b></b>
2060-
2061-
<script>
2062-
$( "b" ).append( "" + $.isArray([]) );
2063-
</script>
2064-
2065-
</body>
2066-
</html>
2067-
```
2068-
*/
2069-
isArray(obj: any): obj is any[];
20702032
/**
20712033
* Check to see if an object is empty (contains no enumerable properties).
20722034
* @param obj The object that will be checked to see if it's empty.
@@ -2079,96 +2041,6 @@ jQuery.isEmptyObject({ foo: "bar" }); // false
20792041
```
20802042
*/
20812043
isEmptyObject(obj: any): boolean;
2082-
/**
2083-
* Determine if the argument passed is a JavaScript function object.
2084-
* @param obj Object to test whether or not it is a function.
2085-
* @see \`{@link https://api.jquery.com/jQuery.isFunction/ }\`
2086-
* @since 1.2
2087-
* @deprecated ​ Deprecated since 3.3. Use `typeof x === "function"`.
2088-
* @example ​ ````Test a few parameter examples.
2089-
```html
2090-
<!doctype html>
2091-
<html lang="en">
2092-
<head>
2093-
<meta charset="utf-8">
2094-
<title>jQuery.isFunction demo</title>
2095-
<style>
2096-
div {
2097-
color: blue;
2098-
margin: 2px;
2099-
font-size: 14px;
2100-
}
2101-
span {
2102-
color: red;
2103-
}
2104-
</style>
2105-
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
2106-
</head>
2107-
<body>
2108-
2109-
<div>jQuery.isFunction( objs[ 0 ] ) = <span></span></div>
2110-
<div>jQuery.isFunction( objs[ 1 ] ) = <span></span></div>
2111-
<div>jQuery.isFunction( objs[ 2 ] ) = <span></span></div>
2112-
<div>jQuery.isFunction( objs[ 3 ] ) = <span></span></div>
2113-
<div>jQuery.isFunction( objs[ 4 ] ) = <span></span></div>
2114-
2115-
<script>
2116-
function stub() {}
2117-
var objs = [
2118-
function() {},
2119-
{ x:15, y:20 },
2120-
null,
2121-
stub,
2122-
"function"
2123-
];
2124-
2125-
jQuery.each( objs, function( i ) {
2126-
var isFunc = jQuery.isFunction( objs[ i ]);
2127-
$( "span" ).eq( i ).text( isFunc );
2128-
});
2129-
</script>
2130-
2131-
</body>
2132-
</html>
2133-
```
2134-
* @example ​ ````Finds out if the parameter is a function.
2135-
```javascript
2136-
$.isFunction(function() {});
2137-
```
2138-
*/
2139-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
2140-
isFunction(obj: any): obj is Function;
2141-
/**
2142-
* Determines whether its argument represents a JavaScript number.
2143-
* @param value The value to be tested.
2144-
* @see \`{@link https://api.jquery.com/jQuery.isNumeric/ }\`
2145-
* @since 1.7
2146-
* @deprecated ​ Deprecated since 3.3. Internal. See \`{@link https://github.com/jquery/jquery/issues/2960 }\`.
2147-
* @example ​ ````Sample return values of $.isNumeric with various inputs.
2148-
```javascript
2149-
// true (numeric)
2150-
$.isNumeric( "-10" )
2151-
$.isNumeric( "0" )
2152-
$.isNumeric( 0xFF )
2153-
$.isNumeric( "0xFF" )
2154-
$.isNumeric( "8e5" )
2155-
$.isNumeric( "3.1415" )
2156-
$.isNumeric( +10 )
2157-
$.isNumeric( 0144 )
2158-
2159-
// false (non-numeric)
2160-
$.isNumeric( "-0x42" )
2161-
$.isNumeric( "7.2acdgs" )
2162-
$.isNumeric( "" )
2163-
$.isNumeric( {} )
2164-
$.isNumeric( NaN )
2165-
$.isNumeric( null )
2166-
$.isNumeric( true )
2167-
$.isNumeric( Infinity )
2168-
$.isNumeric( undefined )
2169-
```
2170-
*/
2171-
isNumeric(value: any): boolean;
21722044
/**
21732045
* Check to see if an object is a plain object (created using "{}" or "new Object").
21742046
* @param obj The object that will be checked to see if it's a plain object.
@@ -2181,38 +2053,6 @@ jQuery.isPlainObject( "test" ) // false
21812053
```
21822054
*/
21832055
isPlainObject(obj: any): boolean;
2184-
/**
2185-
* Determine whether the argument is a window.
2186-
* @param obj Object to test whether or not it is a window.
2187-
* @see \`{@link https://api.jquery.com/jQuery.isWindow/ }\`
2188-
* @since 1.4.3
2189-
* @deprecated ​ Deprecated since 3.3. Internal. See \`{@link https://github.com/jquery/jquery/issues/3629 }\`.
2190-
*
2191-
* **Cause**: This method returns `true` if its argument is thought to be a `window` element. It was created for internal use and is not a reliable way of detecting `window` for public needs.
2192-
*
2193-
* **Solution**: Remove any use of `jQuery.isWindow()` from code. If it is truly needed it can be replaced with a check for `obj != null && obj === obj.window` which was the test used inside this method.
2194-
* @example ​ ````Finds out if the parameter is a window.
2195-
```html
2196-
<!doctype html>
2197-
<html lang="en">
2198-
<head>
2199-
<meta charset="utf-8">
2200-
<title>jQuery.isWindow demo</title>
2201-
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
2202-
</head>
2203-
<body>
2204-
2205-
Is 'window' a window? <b></b>
2206-
2207-
<script>
2208-
$( "b" ).append( "" + $.isWindow( window ) );
2209-
</script>
2210-
2211-
</body>
2212-
</html>
2213-
```
2214-
*/
2215-
isWindow(obj: any): obj is Window;
22162056
/**
22172057
* Check to see if a DOM node is within an XML document (or is an XML document).
22182058
* @param node The DOM node that will be checked to see if it's in an XML document.
@@ -2495,27 +2335,12 @@ $log.append( "2nd loaded jQuery version (jq162): " + jq162.fn.jquery + "<br>" );
24952335
```
24962336
*/
24972337
noConflict(removeAll?: boolean): this;
2498-
/**
2499-
* @deprecated ​ Deprecated since 3.2.
2500-
*
2501-
* **Cause**: This public but never-documented method has been deprecated as of jQuery 3.2.0.
2502-
*
2503-
* **Solution**: Replace calls such as `jQuery.nodeName( elem, "div" )` with a test such as `elem.nodeName.toLowerCase() === "div"`.
2504-
*/
2505-
nodeName(elem: Node, name: string): boolean;
25062338
/**
25072339
* An empty function.
25082340
* @see \`{@link https://api.jquery.com/jQuery.noop/ }\`
25092341
* @since 1.4
25102342
*/
25112343
noop(): undefined;
2512-
/**
2513-
* Return a number representing the current time.
2514-
* @see \`{@link https://api.jquery.com/jQuery.now/ }\`
2515-
* @since 1.4.3
2516-
* @deprecated ​ Deprecated since 3.3. Use \`{@link DateConstructor.now Date.now}\`.
2517-
*/
2518-
now(): number;
25192344
/**
25202345
* Create a serialized representation of an array, a plain object, or a jQuery object suitable for use in a URL query string or Ajax request. In case a jQuery object is passed, it should contain input elements with name/value properties.
25212346
* @param obj An array, a plain object, or a jQuery object to serialize.
@@ -2645,23 +2470,6 @@ $( "<ol></ol>" )
26452470
```
26462471
*/
26472472
parseHTML(data: string, context_keepScripts?: Document | null | boolean): JQuery.Node[];
2648-
/**
2649-
* Takes a well-formed JSON string and returns the resulting JavaScript value.
2650-
* @param json The JSON string to parse.
2651-
* @see \`{@link https://api.jquery.com/jQuery.parseJSON/ }\`
2652-
* @since 1.4.1
2653-
* @deprecated ​ Deprecated since 3.0. Use \`{@link JSON.parse }\`.
2654-
*
2655-
* **Cause**: The `jQuery.parseJSON` method in recent jQuery is identical to the native `JSON.parse`. As of jQuery 3.0 `jQuery.parseJSON` is deprecated.
2656-
*
2657-
* **Solution**: Replace any use of `jQuery.parseJSON` with `JSON.parse`.
2658-
* @example ​ ````Parse a JSON string.
2659-
```javascript
2660-
var obj = jQuery.parseJSON( '{ "name": "John" }' );
2661-
alert( obj.name === "John" );
2662-
```
2663-
*/
2664-
parseJSON(json: string): any;
26652473
/**
26662474
* Parses a string into an XML document.
26672475
* @param data a well-formed XML string to be parsed
@@ -13586,87 +13394,6 @@ $( "span:eq(3)" ).text( "" + jQuery.data( div, "test2" ) );
1358613394
speed<TElement extends Element = HTMLElement>(
1358713395
duration_complete_settings?: JQuery.Duration | ((this: TElement) => void) | JQuery.SpeedSettings<TElement>,
1358813396
): JQuery.EffectsOptions<TElement>;
13589-
/**
13590-
* Remove the whitespace from the beginning and end of a string.
13591-
* @param str The string to trim.
13592-
* @see \`{@link https://api.jquery.com/jQuery.trim/ }\`
13593-
* @since 1.0
13594-
* @deprecated ​ Deprecated since 3.5. Use \`{@link String.prototype.trim String.prototype.trim}\`.
13595-
* @example ​ ````Remove the white spaces at the start and at the end of the string.
13596-
```html
13597-
<!doctype html>
13598-
<html lang="en">
13599-
<head>
13600-
<meta charset="utf-8">
13601-
<title>jQuery.trim demo</title>
13602-
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
13603-
</head>
13604-
<body>
13605-
13606-
<pre id="original"></pre>
13607-
<pre id="trimmed"></pre>
13608-
13609-
<script>
13610-
var str = " lots of spaces before and after ";
13611-
$( "#original" ).html( "Original String: '" + str + "'" );
13612-
$( "#trimmed" ).html( "$.trim()'ed: '" + $.trim(str) + "'" );
13613-
</script>
13614-
13615-
</body>
13616-
</html>
13617-
```
13618-
* @example ​ ````Remove the white spaces at the start and at the end of the string.
13619-
```javascript
13620-
$.trim(" hello, how are you? ");
13621-
```
13622-
* @example ​ ````Remove the white spaces at the start and at the end of the string.
13623-
```javascript
13624-
$.trim(" hello, how are you? ");
13625-
```
13626-
*/
13627-
trim(str: string): string;
13628-
/**
13629-
* Determine the internal JavaScript [[Class]] of an object.
13630-
* @param obj Object to get the internal JavaScript [[Class]] of.
13631-
* @see \`{@link https://api.jquery.com/jQuery.type/ }\`
13632-
* @since 1.4.3
13633-
* @deprecated ​ Deprecated since 3.3. See \`{@link https://github.com/jquery/jquery/issues/3605 }\`.
13634-
* @example ​ ````Find out if the parameter is a RegExp.
13635-
```html
13636-
<!doctype html>
13637-
<html lang="en">
13638-
<head>
13639-
<meta charset="utf-8">
13640-
<title>jQuery.type demo</title>
13641-
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
13642-
</head>
13643-
<body>
13644-
13645-
Is it a RegExp? <b></b>
13646-
13647-
<script>
13648-
$( "b" ).append( "" + jQuery.type( /test/ ) );
13649-
</script>
13650-
13651-
</body>
13652-
</html>
13653-
```
13654-
*/
13655-
type(
13656-
obj: any,
13657-
):
13658-
| "array"
13659-
| "boolean"
13660-
| "date"
13661-
| "error"
13662-
| "function"
13663-
| "null"
13664-
| "number"
13665-
| "object"
13666-
| "regexp"
13667-
| "string"
13668-
| "symbol"
13669-
| "undefined";
1367013397
/**
1367113398
* Sorts an array of DOM elements, in place, with the duplicates removed. Note that this only works on arrays of DOM elements, not strings or numbers.
1367213399
* @param array The Array of DOM elements.

types/jquery/dist/jquery.slim.d.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

types/jquery/factory-slim.d.mts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path="index.d.ts" />
2+
3+
// jQuery slim factory for environments without a window
4+
// Usage: import { jQueryFactory } from "jquery/factory-slim";
5+
// const $ = jQueryFactory(window);
6+
7+
export declare function jQueryFactory(window: Window): JQueryStatic;

types/jquery/factory-slim.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path="index.d.ts" />
2+
3+
// jQuery slim factory for environments without a window (CommonJS)
4+
// Usage: const { jQueryFactory } = require("jquery/factory-slim");
5+
// const $ = jQueryFactory(window);
6+
7+
export declare function jQueryFactory(window: Window): JQueryStatic;

types/jquery/factory.d.mts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path="index.d.ts" />
2+
3+
// jQuery factory for environments without a window
4+
// Usage: import { jQueryFactory } from "jquery/factory";
5+
// const $ = jQueryFactory(window);
6+
7+
export declare function jQueryFactory(window: Window): JQueryStatic;

types/jquery/factory.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path="index.d.ts" />
2+
3+
// jQuery factory for environments without a window (CommonJS)
4+
// Usage: const { jQueryFactory } = require("jquery/factory");
5+
// const $ = jQueryFactory(window);
6+
7+
export declare function jQueryFactory(window: Window): JQueryStatic;

types/jquery/index.d.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/// <reference path="index.d.ts" />
2+
3+
export default jQuery;
4+
export { jQuery, jQuery as $ };

0 commit comments

Comments
 (0)