-
Notifications
You must be signed in to change notification settings - Fork 665
fix(types): make compatible with Vue 2.5 and TypeScript 2.6 #317
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(types): make compatible with Vue 2.5 and TypeScript 2.6
- Loading branch information
commit 554072c60e33e6d1133328c69a8f3615db50850a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
Component
type from vue package fails, it probably means we need to fix it in the main repo. Would you like to point out the failing usage?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. I found the
Component
type always has the baseVue
type forthis
type ofData
andMethod
in default. That fails type checking ifComponentOptions
has different type: https://github.com/vuejs/vue-test-utils/blob/dev/types/test/resources.ts#L9Maybe we should change the default type parameters of
Component
(andAsyncComponent
) to{}
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we merge this now and update the Component type here later when it's fixed in the main repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge it now. We can change it later after new Vue is released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ktsn The problem is that
Component
isn't correctly setting up type bound.ComponentOption<V>
is contravariant, that is,ComponentOption<Normal>
isn't a sub type ofComponentOption<Vue>
, but ofComponentOption<never>
.beforeCreate
in componentOption would also break assignment here if contravariant method was checked. But currently it is not https://github.com/Microsoft/TypeScript/wiki/What%27s-new-in-TypeScript#noteThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HerringtonDarkholme Thanks for clarify the problem! I didn't realize we can use
never
for the default generic type.I'll change the
ComponentOptions
's 1st type parameter tonever
for now before this PR is merged.