diff --git a/packages/babel-plugin-jsx/src/transform-vue-jsx.ts b/packages/babel-plugin-jsx/src/transform-vue-jsx.ts index 9d77af2f..59fca37d 100644 --- a/packages/babel-plugin-jsx/src/transform-vue-jsx.ts +++ b/packages/babel-plugin-jsx/src/transform-vue-jsx.ts @@ -122,7 +122,7 @@ const transformJSXElement = ( t.isCallExpression(child) && child.loc && isComponent ) { // the element was generated and doesn't have location information const slotId = path.scope.generateUidIdentifier('slot'); - const scope = path.hub.getScope(); + const scope = path.scope; if (scope) { scope.push({ id: slotId, diff --git a/packages/babel-plugin-jsx/test/index.test.tsx b/packages/babel-plugin-jsx/test/index.test.tsx index 846e09d9..4f6e5f3e 100644 --- a/packages/babel-plugin-jsx/test/index.test.tsx +++ b/packages/babel-plugin-jsx/test/index.test.tsx @@ -570,4 +570,24 @@ describe('should support passing object slots via JSX children', () => { expect(wrapper.html()).toBe('foo'); }); + + test('single expression, array map expression', () => { + const Test = defineComponent({ + setup(_, { slots }) { + return () => {slots.default?.()}; + }, + }); + + const data = ['A', 'B', 'C']; + + const wrapper = mount({ + render() { + return ( +
{data.map((item: string) => {item})}
+ ); + }, + }); + + expect(wrapper.html()).toBe('
ABC
'); + }); });