import { ComputedRef, ComputedGetter } from 'vue'; import { OptionalResult } from './types'; /** * Creates a computed reference that wraps the result of a getter function in an `OptionalResult` object. * This wrapper provides error handling, ensuring that if an error occurs during the computation of the result, * the error is captured and included in the `OptionalResult` instead of throwing the error. * * @template V - The type of the value returned by the getter function. * * @param {ComputedGetter} getter - A function that returns a value of type `V`. This function is executed inside * the computed reference and its result is wrapped in an `OptionalResult`. * * @returns {ComputedRef>} - A computed reference containing the result of the getter function * wrapped in an `OptionalResult`. If the getter function executes successfully, the `value` property of the `OptionalResult` * will contain the result. If an error occurs, the `errors` property will contain the error message, and `value` will be `undefined`. * * @example * const myGetter = () => { * if (someCondition) { * throw new Error('An error occurred'); * } * return 'Success'; * }; * * const myComputedResult = computedResult(myGetter); * * // If someCondition is true: * // myComputedResult.value will be { errors: ['An error occurred'], value: undefined } * * // If someCondition is false: * // myComputedResult.value will be { errors: undefined, value: 'Success' } */ export declare function computedResult(getter: ComputedGetter): ComputedRef>; //# sourceMappingURL=computedResult.d.ts.map