Skip to content

inline defineComponent props types are missing #10843

Description

@danielroe

Vue version

3.5.0-alpha.1

Link to minimal reproduction

https://play.vuejs.org/#eNp9UstOAzEM/BUrl7ZSSUHApRQkqDjAARDlGAmttm4J7DpR4i2Vqv13nKz6EK9LZI8njmecjbr2Xq8aVGM1iWWwniEiNx6qgpaXRnE06sqQrb0LDBuY48ISTp3khMRDWCJPmxAkvqPIBZUILSyCq6EnbXsXhgz95PQHuvB+6ohxzSnU5bZlvzdz9f6F3vD7m/2NIQAfnI9jyDEAW65wDDMOlpYJaofpzFL6mTrYUnOm84UOCEIKBJs23zPUDgaGJqPODdEuCWPtq4JRMoDJ3K5yAPCCkTM06rDJ6ICphuJe6Whhl/o9OhKL8whGJa22wvDo2ToSh3c6jCqqyn3eZ4xDg1lGvvOG5ccv+HtcJ8yop4ARwwqN2tW4CGJ9V76dPYjVB8XazRux4L/iM0ZXNWnGjnbT0FzGPuDlae/y5xDjX+LtmpHiVlQadL8Mo+RDpC3+JX0/7qk+2y5DXHxdYUg9xcBTfa6Pj4rKvxX6RLVf3d/siw==

Steps to reproduce

import { createApp } from 'vue';

const app = createApp()

app.component('SomeComponent', defineComponent({
  props: {
    title: String
  },
  setup(props) {
    // @ts-expect-error
    const a: number = props.title
    const b: string = props.title
    return {}
  }
}))

The type of props is incorrectly typed as LooseRequired<Readonly<ExtractPropTypes<{}>> & {}>.

Simply moving the component out of the app.component call makes the types resolve correctly.

What is expected?

I expect the types to be resolved as:

LooseRequired<Readonly<{
    title: string;
} & {} & {}> & {}>

What is actually happening?

The type of props is incorrectly typed as LooseRequired<Readonly<ExtractPropTypes<{}>> & {}>.

System Info

No response

Any additional comments?

This is likely the same or similar cause as #10842 and #10841 but thought I would raise separately as it expresses itself somewhat differently.

Originally uncovered in nuxt/nuxt#27001 - see https://github.com/nuxt/nuxt/actions/runs/8893792664/job/24420717065?pr=27001.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions