[jquery.pjax] Update to use @types/jquery v3 types.

This commit is contained in:
Leonard Thieu
2017-06-19 20:42:19 -04:00
parent ad96e2c5b9
commit bc7d95b409
3 changed files with 11 additions and 14 deletions
+10 -6
View File
@@ -3,17 +3,19 @@
// Definitions by: Junle Li <https://github.com/lijunle>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="jquery" />
/**
* Interface for pjax:popstate event.
*/
interface PjaxPopStateEventObject extends JQueryEventObject {
interface PjaxPopStateEventObject extends JQuery.Event {
/**
* Navigation direction. Could be "back" or "forward".
*/
direction: string
}
interface PjaxSettings extends JQueryAjaxSettings {
interface PjaxSettings extends JQuery.AjaxSettings {
/**
* A jQuery selector indicates where to stick the response body. E.g., $(container).html(xhr.responseBody).
* If it is not defined, the `data-pjax` attribute of the link will be treated as container.
@@ -87,6 +89,8 @@ interface JQuery {
* @return Returns the jQuery object
*/
pjax(delegationSelector: string, containerSelector?: string, options?: PjaxSettings): JQuery;
on(event: 'pjax:popstate', handler: (e: PjaxPopStateEventObject) => void): this;
}
interface JQueryStatic {
@@ -117,7 +121,7 @@ interface PjaxStatic {
* - push: a boolean indicates whether to pushState the URL. Default is true.
* - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false.
*/
click(event: JQueryEventObject, options?: PjaxSettings): void;
click(event: JQuery.Event, options?: PjaxSettings): void;
/**
* PJAX on click handler.
@@ -128,7 +132,7 @@ interface PjaxStatic {
* - push: a boolean indicates whether to pushState the URL. Default is true.
* - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false.
*/
click(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void;
click(event: JQuery.Event, containerSelector?: string, options?: PjaxSettings): void;
/**
* PJAX on form submit handler
@@ -138,7 +142,7 @@ interface PjaxStatic {
* - push: a boolean indicates whether to pushState the URL. Default is true.
* - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false.
*/
submit(event: JQueryEventObject, options?: PjaxSettings): void;
submit(event: JQuery.Event, options?: PjaxSettings): void;
/**
* PJAX on form submit handler
@@ -149,7 +153,7 @@ interface PjaxStatic {
* - push: a boolean indicates whether to pushState the URL. Default is true.
* - replace: a boolean indicates whether to use replaceState instead of pushState. Default is false.
*/
submit(event: JQueryEventObject, containerSelector?: string, options?: PjaxSettings): void;
submit(event: JQuery.Event, containerSelector?: string, options?: PjaxSettings): void;
/**
* Install pjax functions on $.pjax to enable pushState behavior. Does nothing if already enabled.
+1 -3
View File
@@ -1,5 +1,3 @@
import * as jQuery from 'jquery';
function test_fn_pjax() {
$(document).pjax("a");
$(document).pjax("a", "#pjax-container");
@@ -63,7 +61,7 @@ function test_support() {
}
function test_events() {
$(document).on('pjax:popstate', function(e: PjaxPopStateEventObject) {
$(document).on('pjax:popstate', function(e) {
if (e.direction === 'back') {
console.log('pjax:popstate is OK');
}
-5
View File
@@ -12,11 +12,6 @@
"typeRoots": [
"../"
],
"paths": {
"jquery": [
"jquery/v2"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true