Skip to content

Commit

Permalink
types: remove void from Maybe<T> and update SuiteSelectors
Browse files Browse the repository at this point in the history
  • Loading branch information
vonagam committed Sep 26, 2023
1 parent 85f7897 commit b44b1cb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/vest-utils/src/utilityTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type Nullish<T = void> = Nullable<T> | Maybe<T>;

export type Nullable<T> = T | null;

export type Maybe<T> = T | undefined | void;
export type Maybe<T> = T | undefined;

export type OneOrMoreOf<T> = T | T[];

Expand Down
20 changes: 8 additions & 12 deletions packages/vest/src/suiteResult/selectors/suiteSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function suiteSelectors<F extends TFieldName, G extends TGroupName>(

function getWarning(): Maybe<SummaryFailure<F, G>>;
function getWarning(fieldName: F): Maybe<string>;
function getWarning(fieldName?: F): GetSingularResponse<F, G> {
function getWarning(fieldName?: F): Maybe<SummaryFailure<F, G> | string> {
return getFailure<F, G>(Severity.WARNINGS, summary, fieldName as F);
}

Expand All @@ -154,7 +154,7 @@ export function suiteSelectors<F extends TFieldName, G extends TGroupName>(

function getError(): Maybe<SummaryFailure<F, G>>;
function getError(fieldName: F): Maybe<string>;
function getError(fieldName?: F): GetSingularResponse<F, G> {
function getError(fieldName?: F): Maybe<SummaryFailure<F, G> | string> {
return getFailure<F, G>(Severity.ERRORS, summary, fieldName as F);
}

Expand All @@ -181,12 +181,12 @@ 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>;
getWarning(): SummaryFailure<F, G> | undefined;
getWarning(fieldName: F): string | undefined;
getWarning(fieldName?: F): SummaryFailure<F, G> | string | undefined;
getError(): SummaryFailure<F, G> | undefined;
getError(fieldName: F): string | undefined;
getError(fieldName?: F): SummaryFailure<F, G> | string | undefined;
getErrors(): FailureMessages;
getErrors(fieldName: F): string[];
getErrors(fieldName?: F): string[] | FailureMessages;
Expand Down Expand Up @@ -311,7 +311,3 @@ function getFailure<F extends TFieldName, G extends TGroupName>(
matchingFieldName(summaryFailure, fieldName)
)?.message;
}

type GetSingularResponse<F extends TFieldName, G extends TGroupName> = Maybe<
string | SummaryFailure<F, G>
>;
34 changes: 17 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5341,7 +5341,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "anyone@workspace:packages/anyone"
dependencies:
vest-utils: ^1.0.3
vest-utils: ^1.1.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -6618,11 +6618,11 @@ __metadata:
languageName: node
linkType: hard

"context@^3.0.12, context@workspace:packages/context":
"context@^3.0.13, context@workspace:packages/context":
version: 0.0.0-use.local
resolution: "context@workspace:packages/context"
dependencies:
vest-utils: ^1.0.3
vest-utils: ^1.1.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -11630,14 +11630,14 @@ __metadata:
languageName: node
linkType: hard

"n4s@^5.0.5, n4s@workspace:packages/n4s":
"n4s@^5.0.6, n4s@workspace:packages/n4s":
version: 0.0.0-use.local
resolution: "n4s@workspace:packages/n4s"
dependencies:
"@types/validator": ^13.11.1
context: ^3.0.12
context: ^3.0.13
validator: 13.9.0
vest-utils: ^1.0.3
vest-utils: ^1.1.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -15544,15 +15544,15 @@ __metadata:
languageName: node
linkType: hard

"vast@^1.0.21, vast@workspace:packages/vast":
"vast@^1.0.22, vast@workspace:packages/vast":
version: 0.0.0-use.local
resolution: "vast@workspace:packages/vast"
dependencies:
vest-utils: ^1.0.3
vest-utils: ^1.1.0
languageName: unknown
linkType: soft

"vest-utils@^1.0.3, vest-utils@workspace:packages/vest-utils":
"vest-utils@^1.1.0, vest-utils@workspace:packages/vest-utils":
version: 0.0.0-use.local
resolution: "vest-utils@workspace:packages/vest-utils"
languageName: unknown
Expand All @@ -15569,20 +15569,20 @@ __metadata:
version: 0.0.0-use.local
resolution: "vest@workspace:packages/vest"
dependencies:
context: ^3.0.12
n4s: ^5.0.5
vast: ^1.0.21
vest-utils: ^1.0.3
vestjs-runtime: ^1.0.3
context: ^3.0.13
n4s: ^5.0.6
vast: ^1.0.22
vest-utils: ^1.1.0
vestjs-runtime: ^1.0.4
languageName: unknown
linkType: soft

"vestjs-runtime@^1.0.3, vestjs-runtime@workspace:packages/vestjs-runtime":
"vestjs-runtime@^1.0.4, vestjs-runtime@workspace:packages/vestjs-runtime":
version: 0.0.0-use.local
resolution: "vestjs-runtime@workspace:packages/vestjs-runtime"
dependencies:
context: ^3.0.12
vest-utils: ^1.0.3
context: ^3.0.13
vest-utils: ^1.1.0
languageName: unknown
linkType: soft

Expand Down

0 comments on commit b44b1cb

Please sign in to comment.