(condition: unknown, debugInfo?: unknown)
| 27 | assertSingleVersion() |
| 28 | |
| 29 | function assert(condition: unknown, debugInfo?: unknown): asserts condition { |
| 30 | if (condition) { |
| 31 | return |
| 32 | } |
| 33 | |
| 34 | const debugStr = (() => { |
| 35 | if (!debugInfo) { |
| 36 | return '' |
| 37 | } |
| 38 | const debugInfoSerialized = typeof debugInfo === 'string' ? debugInfo : '`' + JSON.stringify(debugInfo) + '`' |
| 39 | return `Debug info (this is for the ${projectInfo.projectName} maintainers; you can ignore this): ${debugInfoSerialized}.` |
| 40 | })() |
| 41 | |
| 42 | const internalError = createErrorWithCleanStackTrace( |
| 43 | [ |
| 44 | `${internalErrorPrefix} You stumbled upon a bug in ${projectInfo.projectName}'s source code.`, |
| 45 | `Reach out at ${projectInfo.githubRepository}/issues/new and include this error stack (the error stack is usually enough to fix the problem).`, |
| 46 | 'A maintainer will fix the bug (usually under 24 hours).', |
| 47 | `Do not hesitate to reach out as it makes ${projectInfo.projectName} more robust.`, |
| 48 | debugStr, |
| 49 | ].join(' '), |
| 50 | numberOfStackTraceLinesToRemove, |
| 51 | ) |
| 52 | |
| 53 | throw internalError |
| 54 | } |
| 55 | |
| 56 | function assertUsage(condition: unknown, errorMessage: string): asserts condition { |
| 57 | if (condition) { |
no test coverage detected
searching dependent graphs…