Skip to content
New issue

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

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

Already on GitHub? # to your account

inline defineComponent props types are missing #10843

Closed
danielroe opened this issue Apr 30, 2024 · 1 comment
Closed

inline defineComponent props types are missing #10843

danielroe opened this issue Apr 30, 2024 · 1 comment

Comments

@danielroe
Copy link
Member

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.

@yyx990803
Copy link
Member

closed via 908f70a

@github-actions github-actions bot locked and limited conversation to collaborators May 19, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants