Skip to content

Commit eeb14a5

Browse files
committed
use generateUidIdentifier
1 parent 4b3867b commit eeb14a5

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

packages/babel-plugin-lingui-macro/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ export default function ({
245245
),
246246
transformElement:
247247
config.macro.jsxRuntime === "solid"
248-
? wrapJsxElementAsComponent
248+
? (value) =>
249+
wrapJsxElementAsComponent(value, path.scope)
249250
: undefined,
250251
isLinguiIdentifier: (node: Identifier, macro) =>
251252
isLinguiIdentifier(path, node, macro),

packages/babel-plugin-lingui-macro/src/messageDescriptorUtils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ObjectExpression,
66
Expression,
77
} from "@babel/types"
8+
import type { Scope } from "@babel/traverse"
89
import { EXTRACT_MARK, MsgDescriptorPropKey } from "./constants"
910
import * as types from "@babel/types"
1011
import { generateMessageId } from "@lingui/message-utils/generateMessageId"
@@ -166,12 +167,15 @@ function createValuesProperty(key: string, values: Record<string, Expression>) {
166167
)
167168
}
168169

169-
export function wrapJsxElementAsComponent(value: Expression): Expression {
170+
export function wrapJsxElementAsComponent(
171+
value: Expression,
172+
scope: Scope,
173+
): Expression {
170174
if (!types.isJSXElement(value)) {
171175
return value
172176
}
173177

174-
const props = types.identifier("props")
178+
const props = scope.generateUidIdentifier("props")
175179

176180
return types.arrowFunctionExpression(
177181
[props],

packages/babel-plugin-lingui-macro/test/__snapshots__/jsx-trans.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ import { Trans as _Trans } from "@lingui/solid";
10191019
id: "lqG909",
10201020
message: "Hello <0>docs</0>.",
10211021
components: {
1022-
0: (props) => <a href="/docs" {...props} />,
1022+
0: (_props) => <a href="/docs" {..._props} />,
10231023
},
10241024
}
10251025
}

0 commit comments

Comments
 (0)