Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types(vest): add more method overloads to SuiteSelectors type #1070

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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