(condition: boolean, format?: string, ...args: any[])
| 20 | } |
| 21 | |
| 22 | function invariant(condition: boolean, format?: string, ...args: any[]) { |
| 23 | validateFormat(format); |
| 24 | |
| 25 | if (!condition) { |
| 26 | let error: Error & { framesToPop?: number }; |
| 27 | if (format === undefined) { |
| 28 | error = new Error( |
| 29 | 'Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.' |
| 30 | ); |
| 31 | } else { |
| 32 | let argIndex = 0; |
| 33 | error = new Error(format.replace(/%s/g, () => args[argIndex++])); |
| 34 | error.name = 'Invariant Violation'; |
| 35 | } |
| 36 | |
| 37 | error.framesToPop = 1; // we don't care about invariant's own frame |
| 38 | throw error; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | export default invariant; |
no test coverage detected
searching dependent graphs…