From a45eda0042b4ec8cdfa34c4909e8a4c56614f16d Mon Sep 17 00:00:00 2001 From: "claude[bot]" <41898282+claude[bot]@users.noreply.github.com> Date: Sat, 21 Mar 2026 00:34:34 +0000 Subject: [PATCH] test(formatjs): Add regression test for issue #532 string concatenation in defaultMessage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds an explicit regression test that reproduces the exact code from issue #532, verifying that string concatenation like 'Hello ' + 'world' in defaultMessage is properly evaluated rather than producing an empty array. Co-authored-by: Donny/강동윤 --- packages/formatjs/__tests__/wasm.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/formatjs/__tests__/wasm.test.ts b/packages/formatjs/__tests__/wasm.test.ts index 29780795a..93dbef47f 100644 --- a/packages/formatjs/__tests__/wasm.test.ts +++ b/packages/formatjs/__tests__/wasm.test.ts @@ -111,6 +111,24 @@ describe("formatjs swc plugin", () => { expect(output).not.toMatch(/description/); }); + // Regression test for https://github.com/swc-project/plugins/issues/532 + it("should handle string concatenation in defaultMessage (issue #532)", async () => { + const input = ` + import { defineMessage } from 'react-intl'; + + const message = defineMessage({ + defaultMessage: 'Hello ' + 'world' + }); + `; + + const output = await transformCode(input); + + expect(output).toMatch(/id: "[^"]+"/); + // Should concatenate strings, not produce an empty array + expect(output).toMatch(/defaultMessage: "Hello world"/); + expect(output).not.toMatch(/defaultMessage: \[\]/); + }); + it("should handle multiple string concatenations", async () => { const input = ` import { defineMessage } from 'react-intl';