From f2a4da08542567b77fc2ae8ebf9385f6d8055f6f Mon Sep 17 00:00:00 2001 From: Sergio Moreno Date: Thu, 4 Mar 2021 14:49:26 +0100 Subject: [PATCH] fix: macro components should omit key prop #994 --- packages/macro/src/macroJsx.test.ts | 28 ++++++++++++++++++++++++++++ packages/macro/src/macroJsx.ts | 1 + 2 files changed, 29 insertions(+) diff --git a/packages/macro/src/macroJsx.test.ts b/packages/macro/src/macroJsx.test.ts index 47abf0111..8c6e4bf16 100644 --- a/packages/macro/src/macroJsx.test.ts +++ b/packages/macro/src/macroJsx.test.ts @@ -139,6 +139,34 @@ describe("jsx macro", () => { }) }) + it("plural with key should be omitted", () => { + const macro = createMacro() + const exp = parseExpression( + `` + ) + const tokens = macro.tokenizeChoiceComponent(exp) + expect(tokens).toEqual({ + type: "arg", + name: "count", + value: expect.objectContaining({ + name: "count", + type: "Identifier", + }), + format: "plural", + options: { + "=0": "No books", + one: "# book", + other: "# books", + }, + }) + }) + it("plural with template literal", () => { const macro = createMacro() const exp = parseExpression( diff --git a/packages/macro/src/macroJsx.ts b/packages/macro/src/macroJsx.ts index c66466018..506d2e487 100644 --- a/packages/macro/src/macroJsx.ts +++ b/packages/macro/src/macroJsx.ts @@ -273,6 +273,7 @@ export default class MacroJSX { ID, COMMENT, MESSAGE, + "key", // we remove react props that are not useful for translation "render", "component",