Skip to content

Commit 27bcf2e

Browse files
test(formatjs): Add regression test for issue #532 string concatenation in defaultMessage (#594)
Fixes #532 Adds an explicit regression test reproducing the exact code from issue #532, verifying that string concatenation like `'Hello ' + 'world'` in `defaultMessage` is properly evaluated rather than producing an empty array. Generated with [Claude Code](https://claude.ai/code) Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
1 parent a6f0c50 commit 27bcf2e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

packages/formatjs/__tests__/wasm.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ describe("formatjs swc plugin", () => {
111111
expect(output).not.toMatch(/description/);
112112
});
113113

114+
// Regression test for https://github.com/swc-project/plugins/issues/532
115+
it("should handle string concatenation in defaultMessage (issue #532)", async () => {
116+
const input = `
117+
import { defineMessage } from 'react-intl';
118+
119+
const message = defineMessage({
120+
defaultMessage: 'Hello ' + 'world'
121+
});
122+
`;
123+
124+
const output = await transformCode(input);
125+
126+
expect(output).toMatch(/id: "[^"]+"/);
127+
// Should concatenate strings, not produce an empty array
128+
expect(output).toMatch(/defaultMessage: "Hello world"/);
129+
expect(output).not.toMatch(/defaultMessage: \[\]/);
130+
});
131+
114132
it("should handle multiple string concatenations", async () => {
115133
const input = `
116134
import { defineMessage } from 'react-intl';

0 commit comments

Comments
 (0)