mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
require format/message string for invariant (#44098)
* require format/message string for invariant * works on 2.2.4 (latest)
This commit is contained in:
parent
c04129c8aa
commit
b563b0da59
6
types/invariant/index.d.ts
vendored
6
types/invariant/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for invariant 2.2.0
|
||||
// Type definitions for invariant 2.2.4
|
||||
// Project: https://github.com/zertosh/invariant
|
||||
// Definitions by: MichaelBennett <https://github.com/bennett000>
|
||||
// dtinth <https://github.com/dtinth>
|
||||
@ -12,8 +12,8 @@ export as namespace invariant;
|
||||
|
||||
declare namespace invariant {
|
||||
interface InvariantStatic {
|
||||
(testValue:false, format?:string, ...extra:any[]):never;
|
||||
(testValue:any, format?:string, ...extra:any[]):void;
|
||||
(testValue:false, format:string, ...extra:any[]):never;
|
||||
(testValue:any, format:string, ...extra:any[]):void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import invariant = require("invariant");
|
||||
|
||||
// will throw in dev mode (process.env.NODE_ENV !== 'production')
|
||||
// $ExpectError
|
||||
invariant(true);
|
||||
|
||||
// will pass in production (process.env.NODE_ENV === 'production')
|
||||
// $ExpectError
|
||||
invariant(true);
|
||||
|
||||
// will pass in dev mode and production mode
|
||||
@ -22,4 +24,4 @@ invariant('', 'Some other error');
|
||||
invariant(true, 'Error, error, read all about it', 37, {}, 'hello');
|
||||
|
||||
// $ExpectType {}
|
||||
({} as {} | undefined) || invariant(false, 'a is undefined');
|
||||
({} as {} | undefined) || invariant(false, 'a is undefined');
|
||||
|
||||
4
types/invariant/ts3.7/index.d.ts
vendored
4
types/invariant/ts3.7/index.d.ts
vendored
@ -5,7 +5,7 @@ export as namespace invariant;
|
||||
|
||||
declare namespace invariant {
|
||||
interface InvariantStatic {
|
||||
(testValue: false, format?: string, ...extra: any[]): never;
|
||||
(testValue: any, format?: string, ...extra: any[]): asserts testValue;
|
||||
(testValue: false, format: string, ...extra: any[]): never;
|
||||
(testValue: any, format: string, ...extra: any[]): asserts testValue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,9 +8,11 @@ invariant(val, 'val must be truthy');
|
||||
val.a === 1;
|
||||
|
||||
// will throw in dev mode (process.env.NODE_ENV !== 'production')
|
||||
// $ExpectError
|
||||
invariant(true);
|
||||
|
||||
// will pass in production (process.env.NODE_ENV === 'production')
|
||||
// $ExpectError
|
||||
invariant(true);
|
||||
|
||||
// will pass in dev mode and production mode
|
||||
|
||||
Loading…
Reference in New Issue
Block a user