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

types: fix mount infer prop type #274

Merged
merged 4 commits into from Dec 19, 2020
Merged

types: fix mount infer prop type #274

merged 4 commits into from Dec 19, 2020

Conversation

pikax
Copy link
Member

@pikax pikax commented Dec 14, 2020

fix #237

Fix issue of not making default properties as optional.

Allow to pass extra props (same behaviour as h)

Commented on tests which prevented extra props.

Copy link
Member

@cexbrayat cexbrayat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I liked not being able to pass extra props, because it catches error like mount(Foo, { typo: value}) if the props is type. But I understand the reasoning.

It would be aswome to squash the 2 commits into one to have a clearer history. And maybe remove the commented tests, or even better, fix them instead of commenting them (because we won't remember why they are commented :) ).

src/types.ts Show resolved Hide resolved
src/types.ts Outdated Show resolved Hide resolved
props: { a: 'Hello', c: 2 }
})
)
// // can not receive extra props
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we don't need these anymore? Shouldn't these continue to error out if we infer the props?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make the passing props a bit more relaxed, is also the same behaviour as h#vue-next

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to uncomment the test and remove the expectError then, with a comment explaining that extra props is allowed as it is for h(). I don't like having commented code, because we will forget why ^^. And if the tests check that extra props are allowed, we are sure to avoid regressions in the future.

@lmiller1990 lmiller1990 self-requested a review December 16, 2020 04:27
@lmiller1990
Copy link
Member

@cexbrayat any more comments or can you drop a ✅

@pikax
Copy link
Member Author

pikax commented Dec 17, 2020

Made the changes, also added the PublicProps to all the overloads, but just wondering if that behaviour is expected on the test utils :

//https://github.com/vuejs/vue-next/blob/master/packages/runtime-core/src/vnode.ts#L87-L98
export type VNodeProps = {
  key?: string | number
  ref?: VNodeRef

  // vnode hooks
  onVnodeBeforeMount?: VNodeMountHook | VNodeMountHook[]
  onVnodeMounted?: VNodeMountHook | VNodeMountHook[]
  onVnodeBeforeUpdate?: VNodeUpdateHook | VNodeUpdateHook[]
  onVnodeUpdated?: VNodeUpdateHook | VNodeUpdateHook[]
  onVnodeBeforeUnmount?: VNodeMountHook | VNodeMountHook[]
  onVnodeUnmounted?: VNodeMountHook | VNodeMountHook[]
}

@cexbrayat cexbrayat self-requested a review December 18, 2020 17:20
Copy link
Member

@cexbrayat cexbrayat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @pikax !

@lmiller1990 It would be awesome to have a release with this change so we can check if everything is fine in our respective projects 😃

@lmiller1990 lmiller1990 merged commit c5d3130 into vuejs:master Dec 19, 2020
@lmiller1990
Copy link
Member

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 this pull request may close these issues.

Typescript error when mounting component with boolean prop
3 participants