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

Type of prop with a default value is incorrect #658

Closed
sylvaingi opened this issue Mar 11, 2021 · 0 comments · Fixed by #660
Closed

Type of prop with a default value is incorrect #658

sylvaingi opened this issue Mar 11, 2021 · 0 comments · Fixed by #660

Comments

@sylvaingi
Copy link

When upgrading to v1.0.0-rc.4, I'm getting a lot of type errors on components using props with a default value.
It looks like #655 introduced this regression.

Using the following component, the props argument of setup() is typed differently between rc.3 and rc.4:

export default defineComponent({
  props: {
    id: { type: String, default: 'def' },
    count: { type: Number, required: true },
  },
  setup(props) {},
});

rc.3:

props: {
    id: string;
    count: number;
} & {}

rc.4:

props: {
    count: number;
} & {
    id?: string | undefined;
}

rc.4 is incorrect here as the id prop will never be undefined at runtime, as it receives the default value if one wasn't provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant