personal web client for Bluesky
typescript solidjs bluesky atcute

refactor: assert arrow fn

mary.my.id 538b409d febc22be

verified
Changed files
+12 -6
src
lib
utils
+12 -6
src/lib/utils/invariant.ts
··· 1 - export function assert(condition: any, message?: string): asserts condition { 1 + export const assert: { 2 + (condition: any, message?: string): asserts condition; 3 + } = (condition, message): asserts condition => { 2 4 if (import.meta.env.DEV && !condition) { 3 5 throw new Error(`Assertion failed` + (message ? `: ${message}` : ``)); 4 6 } 5 - } 7 + }; 6 8 7 - export function assertStrong(condition: any, message?: string): asserts condition { 9 + export const assertStrong: { 10 + (condition: any, message?: string): asserts condition; 11 + } = (condition, message): asserts condition => { 8 12 if (!condition) { 9 13 if (import.meta.env.DEV) { 10 14 throw new Error(`Assertion failed` + (message ? `: ${message}` : ``)); ··· 12 16 13 17 throw new Error(`Assertion failed`); 14 18 } 15 - } 19 + }; 16 20 17 - export function assertUnreachable(_: never, message?: string): never { 21 + export const assertUnreachable: { 22 + (_: never, message?: string): never; 23 + } = (_, message) => { 18 24 assertStrong(false, message); 19 - } 25 + };