Skip to content

Commit 1e84dfe

Browse files
committed
refactor(macros): remove unused props for defineComponent
1 parent db1fb7f commit 1e84dfe

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

packages/macros/src/core/define-component/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function transformDefineComponent(
5353
s.overwrite(
5454
root.params[0].start!,
5555
root.params[0].end!,
56-
`${HELPER_PREFIX}props`,
56+
root.params.length > 1 ? `${HELPER_PREFIX}props` : '',
5757
)
5858
} else if (root.params[0].type === 'ObjectPattern') {
5959
const restructuredProps = root.params[0]

packages/macros/src/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export function transformJsxMacros(
9797
)
9898
}
9999
}
100-
} else {
100+
} else if (macros.defineModel?.length) {
101101
s.appendRight(getParamsStart(root, s.original), propsName)
102102
}
103103

packages/macros/tests/__snapshots__/fixtures.spec.ts.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const Comp = defineComponent(
3939
}, ...{ Comp: Object }} },
4040
)
4141
42-
const Comp1 = defineComponent((__MACROS_props) => {const props = __MACROS_useFullProps();
42+
const Comp1 = defineComponent(() => {const props = __MACROS_useFullProps();
4343
const foo = __MACROS_useModel(props, 'foo')
4444
return () => <div>
4545
{[foo.value, props['bar'], props['onUpdate:bar']]}
@@ -54,7 +54,7 @@ const Comp1 = defineComponent((__MACROS_props) => {const props = __MACROS_useFul
5454
'fooModifiers': null
5555
} })
5656
57-
const Comp2 = defineComponent(async (__MACROS_props) => {
57+
const Comp2 = defineComponent(async () => {
5858
let __temp, __restore
5959
6060
;(
@@ -140,7 +140,7 @@ const Comp = defineComponent(
140140
}, ...{ Comp: Object }} },
141141
)
142142
143-
const Comp1 = defineComponent((__MACROS_props) => {const props = __MACROS_useFullProps();
143+
const Comp1 = defineComponent(() => {const props = __MACROS_useFullProps();
144144
const foo = __MACROS_useModel(props, 'foo')
145145
return <div>
146146
{[foo.value, props['bar'], props['onUpdate:bar']]}
@@ -155,7 +155,7 @@ const Comp1 = defineComponent((__MACROS_props) => {const props = __MACROS_useFul
155155
'fooModifiers': null
156156
} })
157157
158-
const Comp2 = defineComponent(async (__MACROS_props) => {
158+
const Comp2 = defineComponent(async () => {
159159
let __temp, __restore
160160
161161
;(
@@ -204,7 +204,7 @@ defineComponent((__MACROS_props) => {
204204

205205
exports[`fixtures > ./fixtures/define-expose.tsx 1`] = `
206206
"
207-
import { getCurrentInstance as __MACROS_getCurrentInstance } from "vue-jsx-vapor";export function Comp(__MACROS_props) {
207+
import { getCurrentInstance as __MACROS_getCurrentInstance } from "vue-jsx-vapor";export function Comp() {
208208
;(__MACROS_getCurrentInstance().exposed = {
209209
foo: 1,
210210
})
@@ -257,14 +257,14 @@ export default function (__MACROS_props) {
257257

258258
exports[`fixtures > ./fixtures/define-slots.tsx 1`] = `
259259
"
260-
import { useSlots as __MACROS_useSlots } from "vue";export const Comp = (__MACROS_props) => {
260+
import { useSlots as __MACROS_useSlots } from "vue";export const Comp = () => {
261261
const slots = Object.assign<{
262262
default: () => any
263263
}>({}, __MACROS_useSlots())
264264
return <div>{slots.default?.()}</div>
265265
}
266266
267-
export default function (__MACROS_props) {
267+
export default function () {
268268
const slots = Object.assign({
269269
default: () => <div>default</div>,
270270
},__MACROS_useSlots())
@@ -277,13 +277,13 @@ exports[`fixtures > ./fixtures/define-style.tsx 1`] = `
277277
"import "vue-jsx-vapor/macros/define-style/0?scopeId=4e9d5cd0&scoped=true&lang.css";import style1 from "vue-jsx-vapor/macros/define-style/1?scopeId=13f8dd3a&scoped=true&lang.module.scss";
278278
import { useSlots as __MACROS_useSlots } from "vue";import "vue-jsx-vapor/macros/define-style/2?scopeId=63a7910c&scoped=false&lang.scss";import { defineComponent, ref } from 'vue'
279279
280-
export const Comp = (__MACROS_props) => {
280+
export const Comp = () => {
281281
const color = ref('red')
282282
283283
return <div {...{style:{'--4e9d5cd0-color-value': color.value}}} data-v-4e9d5cd0="" class="foo">foo</div>
284284
}
285285
286-
export default defineComponent((__MACROS_props) => {
286+
export default defineComponent(() => {
287287
const color = ref('red')
288288
const styles = style1
289289
const { default: Default, ...slots } = Object.assign({}, __MACROS_useSlots())

0 commit comments

Comments
 (0)