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): fix ThisType of component options with no props option #7131

Closed
wants to merge 1 commit into from

Conversation

ktsn
Copy link
Member

@ktsn ktsn commented Nov 26, 2017

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

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

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:

Other information:

Previously, if the user does not include props option in component options, ThisType has Record<string, any> in the members of intersection types. Then this.notExistingProperty is already passed if props options is missed.

export default Vue.extend({
  data() {
    this.notExistingProperty // <- this should be an error but currently isn't.
  }
})

I added a default type parameter of Vue.component and Vue.extend to avoid to allow any properties in ThisType when there is no props option.

I did not add a test for this because we need to check a compilation error to confirm that 😛

@HerringtonDarkholme
Copy link
Member

Thanks! IIRC the default never is removed by me because some usages cannot be compiled.

But it might be caused by other typing and I've mistaken it with never. I need some more experiment to confirm it.

@HerringtonDarkholme
Copy link
Member

I have investigated this issue; a lot of compiling error in TS2.6.1, :(

It turns out that never bound isn't the culprit but Component.

Component is declared as the union of two ThisTyped options. This makes ComponentOptions not assignable to Component.

So this is a good fix! Thanks!

And I will make a pull request to fix Component issue.

@ktsn
Copy link
Member Author

ktsn commented Nov 27, 2017

@HerringtonDarkholme Thanks for investigation!
I'm closing this PR in favor of #7135 🙂

@ktsn ktsn closed this Nov 27, 2017
@ktsn ktsn deleted the fix-thistype-with-no-props branch November 27, 2017 10:18
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.

2 participants