/** * Format the result value of an expression for display as a string. */ export function formatExpressionResult(value: any, defaultValue = ''): string { if (value === undefined || value === null) { return defaultValue; } if (typeof value === 'string') { return value; } if (typeof value === 'number' || typeof value === 'boolean') { return value.toString(); } return defaultValue; } /** * Filter function to exclude `null` values */ export function filterOutNullable(value: T): value is NonNullable { return !!value; } /** * Type to make optional properties on a object mandatory. * * interface SomeObject { * uid: string; * price: number | null; * location?: string; * } * * type ValuableObject = MandateProps; */ export type MandateProps = T & { [MK in K]-?: NonNullable; };