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

fix(types): make VNodeDirective properties optional, fix #8013 #8003

Merged
merged 4 commits into from
Oct 22, 2018

Conversation

KaelWD
Copy link
Contributor

@KaelWD KaelWD commented Apr 11, 2018

What kind of change does this PR introduce? (check at least one)

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:
Prevents Property 'oldValue' is missing in type '{ name: string; value: string; }'. when using directives in a render function (see test).

There should probably actually be three different VNodeDirectives:

  • In h('', data) - mostly optional, not readonly
  • In VNodeData (returned from createElement) - normalised, not readonly
  • In DirectiveFunction - the current definition (before this change)

@KaelWD KaelWD changed the title fix(types): make VNodeDirective properties optional fix(types): make VNodeDirective properties optional, fix #8013 Apr 13, 2018
Copy link
Member

@HerringtonDarkholme HerringtonDarkholme left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

Since VNodeDirective has optional properties, we cannot guarantee DirectiveFunction has non-nullable DirectiveBinding as argument. So I think changing VNodeDirective alone is OK.

@KaelWD
Copy link
Contributor Author

KaelWD commented Apr 13, 2018

You're right, console.log(h('div', { directives: [{ name: 'something' }] })) only has name. Inspecting the vnode after it's mounted shows def, modifiers, name.

Vue.directive('something', (el, binding) => { console.log(binding) }) also only has those three defined.

I'm thinking there should still be a separate definition for in vs out though, modifiers is always defined as an empty object but it doesn't make sense to pass that in through h.

Edit: yeah, forgot to check this after the change:
image

@KaelWD
Copy link
Contributor Author

KaelWD commented Apr 17, 2018

Bump @HerringtonDarkholme

edit: ty

@yyx990803 yyx990803 merged commit 99a51b4 into vuejs:dev Oct 22, 2018
f2009 pushed a commit to f2009/vue that referenced this pull request Jan 25, 2019
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.

Unable to use directives in a render function with typescript
3 participants