mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 07:17:04 +00:00
chai: Tighten argument types of assert.throw methods. (#42719)
* Refine argument types of assert.thorw methods. * Add author.
This commit is contained in:
Vendored
+28
-27
@@ -5,12 +5,13 @@
|
||||
// Andrew Brown <https://github.com/AGBrown>,
|
||||
// Olivier Chevet <https://github.com/olivr70>,
|
||||
// Matt Wistrand <https://github.com/mwistrand>,
|
||||
// Josh Goldberg <https://github.com/joshuakgoldberg>
|
||||
// Shaun Luttin <https://github.com/shaunluttin>
|
||||
// Gintautas Miselis <https://github.com/Naktibalda>
|
||||
// Satana Charuwichitratana <https://github.com/micksatana>
|
||||
// Erik Schierboom <https://github.com/ErikSchierboom>
|
||||
// Bogdan Paranytsia <https://github.com/bparan>
|
||||
// Josh Goldberg <https://github.com/joshuakgoldberg>,
|
||||
// Shaun Luttin <https://github.com/shaunluttin>,
|
||||
// Gintautas Miselis <https://github.com/Naktibalda>,
|
||||
// Satana Charuwichitratana <https://github.com/micksatana>,
|
||||
// Erik Schierboom <https://github.com/ErikSchierboom>,
|
||||
// Bogdan Paranytsia <https://github.com/bparan>,
|
||||
// CXuesong <https://github.com/CXuesong>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
@@ -130,7 +131,7 @@ declare namespace Chai {
|
||||
export interface AssertionStatic extends AssertionPrototype {
|
||||
prototype: AssertionPrototype;
|
||||
|
||||
new (target: any, message?: string, ssfi?: Function, lockSsfi?: boolean): Assertion;
|
||||
new(target: any, message?: string, ssfi?: Function, lockSsfi?: boolean): Assertion;
|
||||
|
||||
// Deprecated properties:
|
||||
includeStack: boolean;
|
||||
@@ -170,8 +171,8 @@ declare namespace Chai {
|
||||
}
|
||||
|
||||
interface ShouldThrow {
|
||||
(actual: Function, expected?: string|RegExp, message?: string): void;
|
||||
(actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void;
|
||||
(actual: Function, expected?: string | RegExp, message?: string): void;
|
||||
(actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void;
|
||||
}
|
||||
|
||||
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
|
||||
@@ -364,12 +365,12 @@ declare namespace Chai {
|
||||
|
||||
interface Keys {
|
||||
(...keys: string[]): Assertion;
|
||||
(keys: ReadonlyArray<any>|Object): Assertion;
|
||||
(keys: ReadonlyArray<any> | Object): Assertion;
|
||||
}
|
||||
|
||||
interface Throw {
|
||||
(expected?: string|RegExp, message?: string): Assertion;
|
||||
(constructor: Error|Function, expected?: string|RegExp, message?: string): Assertion;
|
||||
(expected?: string | RegExp, message?: string): Assertion;
|
||||
(constructor: Error | Function, expected?: string | RegExp, message?: string): Assertion;
|
||||
}
|
||||
|
||||
interface RespondTo {
|
||||
@@ -1170,7 +1171,7 @@ declare namespace Chai {
|
||||
* @param fn Function that may throw.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
throw(fn: Function, message?: string): void;
|
||||
throw(fn: () => void, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error with message matching regexp.
|
||||
@@ -1179,7 +1180,7 @@ declare namespace Chai {
|
||||
* @param regExp Potential expected message match.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
throw(fn: Function, regExp: RegExp): void;
|
||||
throw(fn: () => void, regExp: RegExp): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error that is an instance of constructor.
|
||||
@@ -1188,7 +1189,7 @@ declare namespace Chai {
|
||||
* @param constructor Potential expected error constructor.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
throw(fn: Function, constructor: Function, message?: string): void;
|
||||
throw(fn: () => void, constructor: ErrorConstructor, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error that is an instance of constructor
|
||||
@@ -1198,7 +1199,7 @@ declare namespace Chai {
|
||||
* @param constructor Potential expected error constructor.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
throw(fn: Function, constructor: Function, regExp: RegExp): void;
|
||||
throw(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
||||
|
||||
/**
|
||||
* Asserts that fn will throw an error.
|
||||
@@ -1206,7 +1207,7 @@ declare namespace Chai {
|
||||
* @param fn Function that may throw.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
throws(fn: Function, message?: string): void;
|
||||
throws(fn: () => void, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error with message matching regexp.
|
||||
@@ -1215,7 +1216,7 @@ declare namespace Chai {
|
||||
* @param errType Potential expected message match or error constructor.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
throws(fn: Function, errType: RegExp|Function, message?: string): void;
|
||||
throws(fn: () => void, errType: RegExp | ErrorConstructor, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error that is an instance of constructor
|
||||
@@ -1225,7 +1226,7 @@ declare namespace Chai {
|
||||
* @param constructor Potential expected error constructor.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
throws(fn: Function, errType: Function, regExp: RegExp): void;
|
||||
throws(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
||||
|
||||
/**
|
||||
* Asserts that fn will throw an error.
|
||||
@@ -1233,7 +1234,7 @@ declare namespace Chai {
|
||||
* @param fn Function that may throw.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
Throw(fn: Function, message?: string): void;
|
||||
Throw(fn: () => void, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error with message matching regexp.
|
||||
@@ -1242,7 +1243,7 @@ declare namespace Chai {
|
||||
* @param regExp Potential expected message match.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
Throw(fn: Function, regExp: RegExp): void;
|
||||
Throw(fn: () => void, regExp: RegExp): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error that is an instance of constructor.
|
||||
@@ -1251,7 +1252,7 @@ declare namespace Chai {
|
||||
* @param constructor Potential expected error constructor.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
Throw(fn: Function, errType: Function, message?: string): void;
|
||||
Throw(fn: () => void, constructor: ErrorConstructor, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error that is an instance of constructor
|
||||
@@ -1261,7 +1262,7 @@ declare namespace Chai {
|
||||
* @param constructor Potential expected error constructor.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
Throw(fn: Function, errType: Function, regExp: RegExp): void;
|
||||
Throw(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
||||
|
||||
/**
|
||||
* Asserts that fn will not throw an error.
|
||||
@@ -1269,7 +1270,7 @@ declare namespace Chai {
|
||||
* @param fn Function that may throw.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
doesNotThrow(fn: Function, message?: string): void;
|
||||
doesNotThrow(fn: () => void, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error with message matching regexp.
|
||||
@@ -1278,7 +1279,7 @@ declare namespace Chai {
|
||||
* @param regExp Potential expected message match.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
doesNotThrow(fn: Function, regExp: RegExp): void;
|
||||
doesNotThrow(fn: () => void, regExp: RegExp): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error that is an instance of constructor.
|
||||
@@ -1287,7 +1288,7 @@ declare namespace Chai {
|
||||
* @param constructor Potential expected error constructor.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
doesNotThrow(fn: Function, errType: Function, message?: string): void;
|
||||
doesNotThrow(fn: () => void, constructor: ErrorConstructor, message?: string): void;
|
||||
|
||||
/**
|
||||
* Asserts that function will throw an error that is an instance of constructor
|
||||
@@ -1297,7 +1298,7 @@ declare namespace Chai {
|
||||
* @param constructor Potential expected error constructor.
|
||||
* @param message Message to display on error.
|
||||
*/
|
||||
doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void;
|
||||
doesNotThrow(fn: () => void, constructor: ErrorConstructor, regExp: RegExp): void;
|
||||
|
||||
/**
|
||||
* Compares two values using operator.
|
||||
|
||||
Reference in New Issue
Block a user