Merge pull request #7674 from bennett000/invariant

Adds support for invariant 2.2.0
This commit is contained in:
Masahiro Wakame
2016-01-24 00:24:46 +09:00
2 changed files with 39 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
/// <reference path="./invariant.d.ts" />
// will throw in dev mode (process.env.NODE_ENV !== 'production')
invariant(true);
// will pass in production (process.env.NODE_ENV === 'production')
invariant(true);
// will pass in dev mode and production mode
invariant(true, 'Error, error, read all about it');
// will throw in dev mode, and production mode
invariant(false, 'Some other error');
// will throw in dev mode, and production mode
invariant(0, 'Some other error');
// will throw in dev mode, and production mode
invariant('', 'Some other error');
// handles extra variables
invariant(true, 'Error, error, read all about it', 37, {}, 'hello');
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for invariant 2.2.0
// Project: https://github.com/zertosh/invariant
// Definitions by: MichaelBennett <https://github.com/bennett000/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare let invariant:invariant.InvariantStatic;
declare module "invariant" {
export = invariant;
}
declare module invariant {
interface InvariantStatic {
(testValue:any, format?:string, ...extra:any[]):void;
}
}