// this function can be used to ensure there are no missing cases in the handling of a union type export function assertNever(x: never): never { throw new Error(`Unexpected object: ${x}`); } export function assert(expression: boolean, msg: string) { if (!expression) { throw new Error(msg); } } export function assertThrows(callback, msg) { let threw = false; try { callback() } catch (e) { threw = true; } if (!threw) { throw new Error(msg); } }