UNPKG

tsbase

Version:

Base class libraries for TypeScript

29 lines (28 loc) 965 B
/** * An abstraction of the result of an action or command - * Use this pattern to return meaningful results from operations * that may have otherwise been void. */ export declare class Result<T> { Value?: T | undefined; /** * Indicates whether or not the action returning the result was successful - * The lack of errors indicates success. The presence of errors indicates failure. */ get IsSuccess(): boolean; constructor(Value?: T | undefined); /** * Messages indicating why the action returning the result was not successful */ ErrorMessages: string[]; /** * Returns a new result containing errors from this result instance as well as the one passed * @param result */ CombineWith(result: Result<T>): Result<T>; /** * Adds an error to ErrorMessages only when that error is not already present in the collection * @param error */ AddError(error: string): void; }