From 226ef5f14c338f1435fa2c6ca75c3e97e3a7ae48 Mon Sep 17 00:00:00 2001 From: Leonard Thieu Date: Tue, 18 Jul 2017 09:13:58 -0400 Subject: [PATCH] [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. --- types/jquery/index.d.ts | 2 +- types/jquery/jquery-tests.ts | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 4ebb4692f5..2fd196fd41 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -587,7 +587,7 @@ interface JQueryStatic { * @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. * diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 01cc4a345e..0485d05351 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -627,12 +627,8 @@ function JQueryStatic() { } function isEmptyObject() { - function type_guard(obj: object) { - if ($.isEmptyObject(obj)) { - // $ExpectType {} - obj; - } - } + // $ExpectType boolean + $.isEmptyObject({}); } function isFunction() {