From 7100817191ad923805872132f3861c8aa8c7309c Mon Sep 17 00:00:00 2001 From: Venus Vavadiya Date: Fri, 20 Sep 2024 20:05:49 -0500 Subject: [PATCH] fix(types): reorder generic type parameters in Left and Right usage --- packages/effect/src/Micro.ts | 10 +++++----- packages/effect/src/internal/either.ts | 16 ++++++++-------- packages/platform/src/Cookies.ts | 2 +- .../benchmark/TreeFormatter.formatIssueSync.ts | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/effect/src/Micro.ts b/packages/effect/src/Micro.ts index 67dfaead24..483da5fd25 100644 --- a/packages/effect/src/Micro.ts +++ b/packages/effect/src/Micro.ts @@ -380,14 +380,14 @@ export declare namespace MicroExit { * @experimental * @category MicroExit */ - export type Success = Either.Right, A> + export type Success = Either.Right> /** * @since 3.4.6 * @experimental * @category MicroExit */ - export type Failure = Either.Left, A> + export type Failure = Either.Left> } /** @@ -456,7 +456,7 @@ export const exitIsFailure: (self: MicroExit) => self is MicroExit.F * @experimental * @category MicroExit */ -export const exitIsInterrupt = (self: MicroExit): self is Either.Left => +export const exitIsInterrupt = (self: MicroExit): self is Either.Left => exitIsFailure(self) && self.left._tag === "Interrupt" /** @@ -464,7 +464,7 @@ export const exitIsInterrupt = (self: MicroExit): self is Either.Lef * @experimental * @category MicroExit */ -export const exitIsFail = (self: MicroExit): self is Either.Left, A> => +export const exitIsFail = (self: MicroExit): self is Either.Left> => exitIsFailure(self) && self.left._tag === "Fail" /** @@ -472,7 +472,7 @@ export const exitIsFail = (self: MicroExit): self is Either.Left(self: MicroExit): self is Either.Left => +export const exitIsDie = (self: MicroExit): self is Either.Left => exitIsFailure(self) && self.left._tag === "Die" /** diff --git a/packages/effect/src/internal/either.ts b/packages/effect/src/internal/either.ts index ca01e15e2d..1d68fda4c3 100644 --- a/packages/effect/src/internal/either.ts +++ b/packages/effect/src/internal/either.ts @@ -22,10 +22,10 @@ const CommonProto = { [TypeId]: { _R: (_: never) => _ }, - [NodeInspectSymbol](this: Either.Either) { + [NodeInspectSymbol](this: Either.Either) { return this.toJSON() }, - toString(this: Either.Left) { + toString(this: Either.Left) { return format(this.toJSON()) } } @@ -33,13 +33,13 @@ const CommonProto = { const RightProto = Object.assign(Object.create(CommonProto), { _tag: "Right", _op: "Right", - [Equal.symbol](this: Either.Right, that: unknown): boolean { + [Equal.symbol](this: Either.Right, that: unknown): boolean { return isEither(that) && isRight(that) && Equal.equals(this.right, that.right) }, - [Hash.symbol](this: Either.Right) { + [Hash.symbol](this: Either.Right) { return Hash.combine(Hash.hash(this._tag))(Hash.hash(this.right)) }, - toJSON(this: Either.Right) { + toJSON(this: Either.Right) { return { _id: "Either", _tag: this._tag, @@ -51,13 +51,13 @@ const RightProto = Object.assign(Object.create(CommonProto), { const LeftProto = Object.assign(Object.create(CommonProto), { _tag: "Left", _op: "Left", - [Equal.symbol](this: Either.Left, that: unknown): boolean { + [Equal.symbol](this: Either.Left, that: unknown): boolean { return isEither(that) && isLeft(that) && Equal.equals(this.left, that.left) }, - [Hash.symbol](this: Either.Left) { + [Hash.symbol](this: Either.Left) { return Hash.combine(Hash.hash(this._tag))(Hash.hash(this.left)) }, - toJSON(this: Either.Left) { + toJSON(this: Either.Left) { return { _id: "Either", _tag: this._tag, diff --git a/packages/platform/src/Cookies.ts b/packages/platform/src/Cookies.ts index 2828344615..01e262ce08 100644 --- a/packages/platform/src/Cookies.ts +++ b/packages/platform/src/Cookies.ts @@ -552,7 +552,7 @@ export const setAll: { for (const [name, value, options] of cookies) { const either = makeCookie(name, value, options) if (Either.isLeft(either)) { - return either as Either.Left + return either as Either.Left } record[name] = either.right } diff --git a/packages/schema/benchmark/TreeFormatter.formatIssueSync.ts b/packages/schema/benchmark/TreeFormatter.formatIssueSync.ts index e22a6d4e7b..8605550725 100644 --- a/packages/schema/benchmark/TreeFormatter.formatIssueSync.ts +++ b/packages/schema/benchmark/TreeFormatter.formatIssueSync.ts @@ -26,7 +26,7 @@ const schema = S.Struct({ const decodeUnknownEither = S.decodeUnknownEither(schema) const input = { a: { b: { c: "" } } } const result = decodeUnknownEither(input) -const issue = (result as any as Either.Left).left.issue +const issue = (result as any as Either.Left).left.issue // console.log(issue)