Skip to content

Commit 4a1780e

Browse files
committed
fix: allow zero-argument usage of Ember.isBlank, .isEmpty, .isPresent and .isNone
Fixes typed-ember/ember-cli-typescript#258 Fixes typed-ember/ember-cli-typescript#255 Fixes typed-ember/ember-cli-typescript#256 Fixes typed-ember/ember-cli-typescript#254
1 parent abee599 commit 4a1780e

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

types/ember/index.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3117,22 +3117,22 @@ declare module 'ember' {
31173117
/**
31183118
* A value is blank if it is empty or a whitespace string.
31193119
*/
3120-
function isBlank(obj: any): boolean;
3120+
function isBlank(obj?: any): boolean;
31213121
/**
31223122
* Verifies that a value is `null` or an empty string, empty array,
31233123
* or empty function.
31243124
*/
3125-
function isEmpty(obj: any): boolean;
3125+
function isEmpty(obj?: any): boolean;
31263126
/**
31273127
* Returns true if the passed value is null or undefined. This avoids errors
31283128
* from JSLint complaining about use of ==, which can be technically
31293129
* confusing.
31303130
*/
3131-
function isNone(obj: any): obj is null | undefined;
3131+
function isNone(obj?: any): obj is null | undefined;
31323132
/**
31333133
* A value is present if it not `isBlank`.
31343134
*/
3135-
function isPresent(obj: any): boolean;
3135+
function isPresent(obj?: any): boolean;
31363136
/**
31373137
* Merge the contents of two objects together into the first object.
31383138
* @deprecated Use Object.assign

types/ember/test/utils.ts

+25
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,31 @@ function testIsNoneType() {
1414
}
1515

1616
const anotherString = maybeUndefined + 'another string';
17+
utils.isNone(); // $ExpectType boolean
18+
}
19+
20+
function testIsBlank() {
21+
utils.isBlank(); // $ExpectType boolean
22+
utils.isBlank(''); // $ExpectType boolean
23+
utils.isBlank('', ''); // $ExpectError
24+
}
25+
26+
function testIsEmpty() {
27+
utils.isEmpty(); // $ExpectType boolean
28+
utils.isEmpty(''); // $ExpectType boolean
29+
utils.isEmpty('', ''); // $ExpectError
30+
}
31+
32+
function testIsPresent() {
33+
utils.isPresent(); // $ExpectType boolean
34+
utils.isPresent(''); // $ExpectType boolean
35+
utils.isPresent('', ''); // $ExpectError
36+
}
37+
38+
function testIsNone() {
39+
utils.isNone(); // $ExpectType boolean
40+
utils.isNone(''); // $ExpectType boolean
41+
utils.isNone('', ''); // $ExpectError
1742
}
1843

1944
function testMerge() {

0 commit comments

Comments
 (0)