diff --git a/.changeset/fix-cause-tojson-key.md b/.changeset/fix-cause-tojson-key.md new file mode 100644 index 00000000000..b86813affda --- /dev/null +++ b/.changeset/fix-cause-tojson-key.md @@ -0,0 +1,5 @@ +--- +"effect": patch +--- + +fix(Cause): align toJSON key with actual property name diff --git a/packages/effect/src/internal/cause.ts b/packages/effect/src/internal/cause.ts index e557a914235..cfdf8a999f4 100644 --- a/packages/effect/src/internal/cause.ts +++ b/packages/effect/src/internal/cause.ts @@ -60,7 +60,7 @@ const proto = { case "Interrupt": return { _id: "Cause", _tag: this._tag, fiberId: this.fiberId.toJSON() } case "Fail": - return { _id: "Cause", _tag: this._tag, failure: toJSON(this.error) } + return { _id: "Cause", _tag: this._tag, error: toJSON(this.error) } case "Sequential": case "Parallel": return { _id: "Cause", _tag: this._tag, left: toJSON(this.left), right: toJSON(this.right) } diff --git a/packages/effect/test/Cause.test.ts b/packages/effect/test/Cause.test.ts index 0220598384a..a409909442d 100644 --- a/packages/effect/test/Cause.test.ts +++ b/packages/effect/test/Cause.test.ts @@ -123,7 +123,7 @@ describe("Cause", () => { expectJSON(Cause.fail(Option.some(1)), { _id: "Cause", _tag: "Fail", - failure: { + error: { _id: "Option", _tag: "Some", value: 1 @@ -189,12 +189,12 @@ describe("Cause", () => { left: { _id: "Cause", _tag: "Fail", - failure: "failure 1" + error: "failure 1" }, right: { _id: "Cause", _tag: "Fail", - failure: "failure 2" + error: "failure 2" } }) }) @@ -206,12 +206,12 @@ describe("Cause", () => { left: { _id: "Cause", _tag: "Fail", - failure: "failure 1" + error: "failure 1" }, right: { _id: "Cause", _tag: "Fail", - failure: "failure 2" + error: "failure 2" } }) })