Skip to content

Commit

Permalink
types(vest): add more method overloads to SuiteSelectors type
Browse files Browse the repository at this point in the history
  • Loading branch information
vonagam committed Sep 8, 2023
1 parent 9453646 commit 89de099
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/vest/src/suiteResult/selectors/suiteSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export function suiteSelectors<F extends TFieldName, G extends TGroupName>(
return getFailures(summary, Severity.WARNINGS, fieldName);
}

function getWarning(): Maybe<SummaryFailure<F, G>>;
function getWarning(fieldName: F): Maybe<string>;
function getWarning(fieldName?: F): GetSingularResponse<F, G> {
return getFailure<F, G>(Severity.WARNINGS, summary, fieldName as F);
}
Expand All @@ -150,6 +152,8 @@ export function suiteSelectors<F extends TFieldName, G extends TGroupName>(
return getFailures(summary, Severity.ERRORS, fieldName);
}

function getError(): Maybe<SummaryFailure<F, G>>;
function getError(fieldName: F): Maybe<string>;
function getError(fieldName?: F): GetSingularResponse<F, G> {
return getFailure<F, G>(Severity.ERRORS, summary, fieldName as F);
}
Expand Down Expand Up @@ -177,16 +181,24 @@ export function suiteSelectors<F extends TFieldName, G extends TGroupName>(
}

export interface SuiteSelectors<F extends TFieldName, G extends TGroupName> {
getWarning(): Maybe<SummaryFailure<F, G>>;
getWarning(fieldName: F): Maybe<string>;
getWarning(fieldName?: F): GetSingularResponse<F, G>;
getError(): Maybe<SummaryFailure<F, G>>;
getError(fieldName: F): Maybe<string>;
getError(fieldName?: F): GetSingularResponse<F, G>;
getErrors(fieldName: F): string[];
getErrors(): FailureMessages;
getErrors(fieldName: F): string[];
getErrors(fieldName?: F): string[] | FailureMessages;
getWarnings(): FailureMessages;
getWarnings(fieldName: F): string[];
getErrorsByGroup(groupName: G, fieldName: F): string[];
getWarnings(fieldName?: F): string[] | FailureMessages;
getErrorsByGroup(groupName: G): FailureMessages;
getErrorsByGroup(groupName: G, fieldName: F): string[];
getErrorsByGroup(groupName: G, fieldName?: F): string[] | FailureMessages;
getWarningsByGroup(groupName: G): FailureMessages;
getWarningsByGroup(groupName: G, fieldName: F): string[];
getWarningsByGroup(groupName: G, fieldName?: F): string[] | FailureMessages;
hasErrors(fieldName?: F): boolean;
hasWarnings(fieldName?: F): boolean;
hasErrorsByGroup(groupName: G, fieldName?: F): boolean;
Expand Down

0 comments on commit 89de099

Please sign in to comment.