You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: types/assertions.d.cts
+14-3Lines changed: 14 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,8 @@ export type Assertions = {
27
27
/**
28
28
* Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), returning a boolean
29
29
* indicating whether the assertion passed.
30
+
*
31
+
* Note: An `else` clause using this as a type guard will be subtly incorrect for `string` and `number` types and will not give `0` or `''` as a potential value in an `else` clause.
30
32
*/
31
33
assert: AssertAssertion;
32
34
@@ -121,16 +123,23 @@ export type Assertions = {
121
123
/**
122
124
* Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), returning a boolean
123
125
* indicating whether the assertion passed.
126
+
*
127
+
* Note: An `else` clause using this as a type guard will be subtly incorrect for `string` and `number` types and will not give `0` or `''` as a potential value in an `else` clause.
* Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), returning a boolean
131
138
* indicating whether the assertion passed.
139
+
*
140
+
* Note: An `else` clause using this as a type guard will be subtly incorrect for `string` and `number` types and will not give `0` or `''` as a potential value in an `else` clause.
132
141
*/
133
-
(actual: any,message?: string): boolean;
142
+
<T>(actual: T,message?: string): actual is TextendsFalsy<T> ? never : T;
134
143
135
144
/** Skip this assertion. */
136
145
skip(actual: any,message?: string): void;
@@ -192,7 +201,7 @@ export type FalsyAssertion = {
192
201
* Assert that `actual` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy), returning a boolean
193
202
* indicating whether the assertion passed.
194
203
*/
195
-
(actual: any,message?: string): boolean;
204
+
<T>(actual: T,message?: string): actual is Falsy<T>;
196
205
197
206
/** Skip this assertion. */
198
207
skip(actual: any,message?: string): void;
@@ -336,8 +345,10 @@ export type TruthyAssertion = {
336
345
/**
337
346
* Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), returning a boolean
338
347
* indicating whether the assertion passed.
348
+
*
349
+
* Note: An `else` clause using this as a type guard will be subtly incorrect for `string` and `number` types and will not give `0` or `''` as a potential value in an `else` clause.
339
350
*/
340
-
(actual: any,message?: string): boolean;
351
+
<T>(actual: T,message?: string): actual is TextendsFalsy<T> ? never : T;
0 commit comments