export function assertInstanceOf }>( value: unknown, type: T ): InstanceType { if (!(value instanceof type)) { throw new Error(`Expected value to be an instanceof ${typeof type} but got ${typeof value}`); } return value; } export function assertIsDefined(value: T | null | undefined): T { if (value == null) { throw new Error(`Expected value to not be null but got ${typeof value}`); } return value; }