Skip to content

Using defineComponent in <script> with <script setup> takes type error #4927

Open
@qmhc

Description

@qmhc

For components which using both <script> and <script setup>, and using defineComponent in <script>, when I try to generate declaration files from the compilation results, type errors are issued.

Version

3.2.21

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Use vscode to open any project which contains vue and typescript dependencies (can use vite-create to create a vue-ts project), then copy sfc js compilation result into a new ts file.

This is to simulate type diagnostic when generate declaration files.

What is expected?

No type error occurred.

What is actually happening?

image

defineComponent returned type is not assignable to parameter type.

In official example is export a native object, it seems to be the best practice.

image

If so, there will be some warnings when the usage is not recommended?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions