[jquery] Fix imported JQueryStatic not returning a JQuery object when called with window.

This commit is contained in:
Leonard Thieu
2017-06-19 13:36:58 -04:00
parent 0f55ae3965
commit 5b2eb2d872
7 changed files with 38 additions and 10 deletions

View File

@@ -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;

View 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;

View 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;

View 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();

View 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();

View File

@@ -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();

View File

@@ -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"
]
}