Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SFC generate wrong code when use onUpdate:value as defineProps key #8291

Closed
0x-jerry opened this issue May 12, 2023 · 3 comments · Fixed by #7803
Closed

SFC generate wrong code when use onUpdate:value as defineProps key #8291

0x-jerry opened this issue May 12, 2023 · 3 comments · Fixed by #7803

Comments

@0x-jerry
Copy link

Vue version

3.3.1

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-qly3ag?file=src%2FApp.vue,package.json&terminal=dev

Steps to reproduce

Expected "}" but found ":"
  4  |    __name: 'App',
  5  |    props: {
  6  |      onUpdate:value: { type: Function, required: true }
     |                    ^
  7  |    },
  8  |    setup(__props: any, { expose: __expose }) {

image

What is expected?

Generate correct code

What is actually happening?

Generate wrong code

System Info

No response

Any additional comments?

I want to extends Select component of ant-design-vue, then I try to use like this:

import type { SelectProps } from 'ant-design-vue'

export interface ApiSelectProps extends SelectProps {
  api?: () => Promise<SelectProps['options']>
}

const props = defineProps<ApiSelectProps>()

Workaround:

import type { SelectProps } from 'ant-design-vue'
import { selectProps } from 'ant-design-vue/es/select'

export interface ApiSelectProps extends SelectProps {
  api?: () => Promise<SelectProps['options']>
}

const props = defineProps({
  ...selectProps(),
  api: {
    type: Function as PropType<NonNullable<ApiSelectProps['api']>>,
  },
})
@Hccake
Copy link

Hccake commented May 12, 2023

have the same problem

@baiwusanyu-c
Copy link
Member

I found this issue earlier, don't know if this PR will fix it

@github-actions github-actions bot locked and limited conversation to collaborators Sep 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants