From bc7d95b4093eb3817c1f7f93612ce43804e4ad3e Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Mon, 19 Jun 2017 20:42:19 -0400 Subject: [PATCH] [jquery.pjax] Update to use @types/jquery v3 types. --- types/jquery.pjax/index.d.ts | 16 ++++++++++------ types/jquery.pjax/jquery.pjax-tests.ts | 4 +--- types/jquery.pjax/tsconfig.json | 5 ----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/types/jquery.pjax/index.d.ts b/types/jquery.pjax/index.d.ts index a8437533c5..1313217a9c 100644 --- a/types/jquery.pjax/index.d.ts +++ b/types/jquery.pjax/index.d.ts @@ -3,17 +3,19 @@ // Definitions by: Junle Li // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + /** * 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. diff --git a/types/jquery.pjax/jquery.pjax-tests.ts b/types/jquery.pjax/jquery.pjax-tests.ts index 205a1d3cf9..04c9ee5ab3 100644 --- a/types/jquery.pjax/jquery.pjax-tests.ts +++ b/types/jquery.pjax/jquery.pjax-tests.ts @@ -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'); } diff --git a/types/jquery.pjax/tsconfig.json b/types/jquery.pjax/tsconfig.json index 0cd3f55757..5364759f80 100644 --- a/types/jquery.pjax/tsconfig.json +++ b/types/jquery.pjax/tsconfig.json @@ -12,11 +12,6 @@ "typeRoots": [ "../" ], - "paths": { - "jquery": [ - "jquery/v2" - ] - }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true