[chai] Fixed .fail(...) method return type and added overloading (#43098)

* Fixed .fail(...) method return type and added overloading

* Update types/chai/index.d.ts

Co-Authored-By: Jed Mao <jedmao@users.noreply.github.com>

* Update types/chai/index.d.ts

Co-Authored-By: Jed Mao <jedmao@users.noreply.github.com>

* Update types/chai/index.d.ts

Co-Authored-By: Jed Mao <jedmao@users.noreply.github.com>

Co-authored-by: Jed Mao <jedmao@users.noreply.github.com>
This commit is contained in:
Joey Kilpatrick 2020-03-13 21:28:48 -04:00 committed by GitHub
parent 59441845c0
commit 6cd0b5eee4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

19
types/chai/index.d.ts vendored
View File

@ -11,7 +11,8 @@
// Satana Charuwichitratana <https://github.com/micksatana>,
// Erik Schierboom <https://github.com/ErikSchierboom>,
// Bogdan Paranytsia <https://github.com/bparan>,
// CXuesong <https://github.com/CXuesong>
// CXuesong <https://github.com/CXuesong>,
// Joey Kilpatrick <https://github.com/joeykilpatrick>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
@ -103,7 +104,8 @@ declare namespace Chai {
export interface ExpectStatic {
(val: any, message?: string): Assertion;
fail(actual?: any, expected?: any, message?: string, operator?: Operator): void;
fail(message?: string): never;
fail(actual: any, expected: any, message?: string, operator?: Operator): never;
}
export interface AssertStatic extends Assert {
@ -167,7 +169,8 @@ declare namespace Chai {
interface Should extends ShouldAssertion {
not: ShouldAssertion;
fail(actual: any, expected: any, message?: string, operator?: Operator): void;
fail(message?: string): never;
fail(actual: any, expected: any, message?: string, operator?: Operator): never;
}
interface ShouldThrow {
@ -396,6 +399,14 @@ declare namespace Chai {
*/
(expression: any, message?: string): void;
/**
* Throws a failure.
*
* @param message Message to display on error.
* @remarks Node.js assert module-compatible.
*/
fail(message?: string): never;
/**
* Throws a failure.
*
@ -406,7 +417,7 @@ declare namespace Chai {
* @param operator Comparison operator, if not strict equality.
* @remarks Node.js assert module-compatible.
*/
fail<T>(actual?: T, expected?: T, message?: string, operator?: Operator): void;
fail<T>(actual: T, expected: T, message?: string, operator?: Operator): never;
/**
* Asserts that object is truthy.