[jquery] Revert isEmptyObject() to returning boolean.

While the type guard does narrow a value's type to an empty object, the interesting case is when the type is not an empty object. TypeScript narrows the type to never in that case which makes the type guard not very useful.
This commit is contained in:
Leonard Thieu
2017-07-18 09:13:58 -04:00
parent 894db2acc8
commit 226ef5f14c
2 changed files with 3 additions and 7 deletions
+1 -1
View File
@@ -587,7 +587,7 @@ interface JQueryStatic<TElement extends Node = HTMLElement> {
* @see {@link https://api.jquery.com/jQuery.isEmptyObject/}
* @since 1.4
*/
isEmptyObject(obj: any): obj is {};
isEmptyObject(obj: any): boolean;
/**
* Determine if the argument passed is a JavaScript function object.
*
+2 -6
View File
@@ -627,12 +627,8 @@ function JQueryStatic() {
}
function isEmptyObject() {
function type_guard(obj: object) {
if ($.isEmptyObject(obj)) {
// $ExpectType {}
obj;
}
}
// $ExpectType boolean
$.isEmptyObject({});
}
function isFunction() {