From feccfd907b0c47f09eaec5474fb5d91f1bf4ff0a Mon Sep 17 00:00:00 2001 From: Dmitrii Maganov Date: Sat, 16 Sep 2023 15:41:43 +0300 Subject: [PATCH] types: remove `void` from `Maybe` and update `SuiteSelectors` --- packages/vest-utils/src/utilityTypes.ts | 2 +- packages/vest/src/core/test/TestTypes.ts | 2 +- .../vest/src/suiteResult/SummaryFailure.ts | 6 ++---- .../suiteResult/selectors/suiteSelectors.ts | 20 ++++++++----------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/packages/vest-utils/src/utilityTypes.ts b/packages/vest-utils/src/utilityTypes.ts index af61a0706..631741c93 100644 --- a/packages/vest-utils/src/utilityTypes.ts +++ b/packages/vest-utils/src/utilityTypes.ts @@ -12,7 +12,7 @@ export type Nullish = Nullable | Maybe; export type Nullable = T | null; -export type Maybe = T | undefined | void; +export type Maybe = T | undefined; export type OneOrMoreOf = T | T[]; diff --git a/packages/vest/src/core/test/TestTypes.ts b/packages/vest/src/core/test/TestTypes.ts index 3b966e1bf..28eaa7c9f 100644 --- a/packages/vest/src/core/test/TestTypes.ts +++ b/packages/vest/src/core/test/TestTypes.ts @@ -6,7 +6,7 @@ type TestFnPayload = { signal: AbortSignal }; export type TestFn = (payload: TestFnPayload) => TestResult; export type AsyncTest = Promise; -export type TestResult = Maybe; +export type TestResult = Maybe | void; export type WithFieldName = { fieldName: F; diff --git a/packages/vest/src/suiteResult/SummaryFailure.ts b/packages/vest/src/suiteResult/SummaryFailure.ts index b0f099e1e..fbbcc2c0f 100644 --- a/packages/vest/src/suiteResult/SummaryFailure.ts +++ b/packages/vest/src/suiteResult/SummaryFailure.ts @@ -1,5 +1,3 @@ -import { Maybe } from 'vest-utils'; - import { TIsolateTest } from 'IsolateTest'; import { TFieldName, TGroupName } from 'SuiteResultTypes'; import { WithFieldName } from 'TestTypes'; @@ -10,8 +8,8 @@ export class SummaryFailure { constructor( public fieldName: F, - public message: Maybe, - public groupName: Maybe + public message: string | undefined, + public groupName: G | undefined ) {} static fromTestObject( diff --git a/packages/vest/src/suiteResult/selectors/suiteSelectors.ts b/packages/vest/src/suiteResult/selectors/suiteSelectors.ts index 0d064ddf4..68f50fc42 100644 --- a/packages/vest/src/suiteResult/selectors/suiteSelectors.ts +++ b/packages/vest/src/suiteResult/selectors/suiteSelectors.ts @@ -149,7 +149,7 @@ export function suiteSelectors( function getWarning(): Maybe>; function getWarning(fieldName: F): Maybe; - function getWarning(fieldName?: F): GetSingularResponse { + function getWarning(fieldName?: F): Maybe | string> { return getFailure(Severity.WARNINGS, summary, fieldName as F); } @@ -161,7 +161,7 @@ export function suiteSelectors( function getError(): Maybe>; function getError(fieldName: F): Maybe; - function getError(fieldName?: F): GetSingularResponse { + function getError(fieldName?: F): Maybe | string> { return getFailure(Severity.ERRORS, summary, fieldName as F); } @@ -188,12 +188,12 @@ export function suiteSelectors( } export interface SuiteSelectors { - getWarning(): Maybe>; - getWarning(fieldName: F): Maybe; - getWarning(fieldName?: F): GetSingularResponse; - getError(): Maybe>; - getError(fieldName: F): Maybe; - getError(fieldName?: F): GetSingularResponse; + getWarning(): SummaryFailure | undefined; + getWarning(fieldName: F): string | undefined; + getWarning(fieldName?: F): SummaryFailure | string | undefined; + getError(): SummaryFailure | undefined; + getError(fieldName: F): string | undefined; + getError(fieldName?: F): SummaryFailure | string | undefined; getErrors(): FailureMessages; getErrors(fieldName: F): string[]; getErrors(fieldName?: F): string[] | FailureMessages; @@ -319,7 +319,3 @@ function getFailure( matchingFieldName(summaryFailure, fieldName) )?.message; } - -type GetSingularResponse = Maybe< - string | SummaryFailure ->;