mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-07 08:58:49 +08:00
[jquery] Fix imported JQueryStatic not returning a JQuery object when called with window.
This commit is contained in:
4
types/jquery/index.d.ts
vendored
4
types/jquery/index.d.ts
vendored
@@ -25,14 +25,14 @@
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare module 'jquery' {
|
||||
function factory(window: Window): JQueryStatic;
|
||||
function factory(window: Window): JQueryStatic & JQuery;
|
||||
|
||||
const factoryOrJQuery: typeof factory & JQueryStatic;
|
||||
export = factoryOrJQuery;
|
||||
}
|
||||
|
||||
declare module 'jquery/dist/jquery.slim' {
|
||||
function factory(window: Window): JQueryStatic;
|
||||
function factory(window: Window): JQueryStatic & JQuery;
|
||||
|
||||
const factoryOrJQuery: typeof factory & JQueryStatic;
|
||||
export = factoryOrJQuery;
|
||||
|
||||
8
types/jquery/test/jquery-no-window-module-tests.ts
Normal file
8
types/jquery/test/jquery-no-window-module-tests.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import jQueryFactory = require('jquery');
|
||||
|
||||
const jq = jQueryFactory(window);
|
||||
// ExpectType will report 'jq' as 'JQueryStatic<HTMLElement> & JQuery<HTMLElement>' even though the compiler seems to know that 'jq' is 'JQueryStatic<HTMLElement>'
|
||||
// // $ExpectType JQueryStatic<HTMLElement>
|
||||
// jq;
|
||||
// jq === jQuery();
|
||||
jq === jQuery;
|
||||
8
types/jquery/test/jquery-slim-no-window-module-tests.ts
Normal file
8
types/jquery/test/jquery-slim-no-window-module-tests.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import jQueryFactory = require('jquery/dist/jquery.slim');
|
||||
|
||||
const jq = jQueryFactory(window);
|
||||
// ExpectType will report 'jq' as 'JQueryStatic<HTMLElement> & JQuery<HTMLElement>' even though the compiler seems to know that 'jq' is 'JQueryStatic<HTMLElement>'
|
||||
// // $ExpectType JQueryStatic<HTMLElement>
|
||||
// jq;
|
||||
// jq === jQuery();
|
||||
jq === jQuery;
|
||||
8
types/jquery/test/jquery-slim-window-module-tests.ts
Normal file
8
types/jquery/test/jquery-slim-window-module-tests.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import * as jq from 'jquery/dist/jquery.slim';
|
||||
|
||||
const $window = jq(window);
|
||||
// ExpectType will report 'jq' as 'JQueryStatic<HTMLElement> & JQuery<HTMLElement>' even though the compiler seems to know that 'jq' is 'JQuery<HTMLElement>'
|
||||
// // $ExpectType JQuery<HTMLElement>
|
||||
// $window;
|
||||
// $window === jq;
|
||||
$window === jq();
|
||||
8
types/jquery/test/jquery-window-module-tests.ts
Normal file
8
types/jquery/test/jquery-window-module-tests.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import * as jq from 'jquery';
|
||||
|
||||
const $window = jq(window);
|
||||
// ExpectType will report 'jq' as 'JQueryStatic<HTMLElement> & JQuery<HTMLElement>' even though the compiler seems to know that 'jq' is 'JQuery<HTMLElement>'
|
||||
// // $ExpectType JQuery<HTMLElement>
|
||||
// $window;
|
||||
// $window === jq;
|
||||
$window === jq();
|
||||
@@ -1,7 +0,0 @@
|
||||
import factory = require('jquery');
|
||||
const jq = factory(window);
|
||||
jq.noop();
|
||||
|
||||
import slimFactory = require('jquery/dist/jquery.slim');
|
||||
const slim = slimFactory(window);
|
||||
slim.noop();
|
||||
@@ -22,6 +22,9 @@
|
||||
"jquery-tests.ts",
|
||||
"test/example-tests.ts",
|
||||
"test/longdesc-tests.ts",
|
||||
"test/module-tests.ts"
|
||||
"test/jquery-no-window-module-tests.ts",
|
||||
"test/jquery-window-module-tests.ts",
|
||||
"test/jquery-slim-no-window-module-tests.ts",
|
||||
"test/jquery-slim-window-module-tests.ts"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user