-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Update typescript.md to describe how to use typescript types without module bundler (closes #2042) #2137
Closed
Closed
Update typescript.md to describe how to use typescript types without module bundler (closes #2042) #2137
Changes from all commits
Commits
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
There are no files selected for viewing
This file contains 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.
It would make more sense to explicitly describe what the definition file does.
I feel we cannot use Vue's types (like
ComponentOptions
etc.) without this definition which is not correct from this phrase.What about the below change?
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.
Thank you all for reviewing. Yes, wording needs some work to make it clear what is the purpose of this. You can use Vue fine in typescript without importing types or creating custom type definition file with declare global if you can live with errors (javascript still gets generated correctly) and without intellisense and type recognition in IDE.
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.
Better wording very welcome but here is my try.
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.
Wait, is this code really work on your environment? I just try it in my local but there is a compile error on it. I'm using the latest Vue (v2.6.10).
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.
OK, I realized there is already this kind of type declaration in Vue's typings. https://github.com/vuejs/vue/blob/dev/types/index.d.ts#L5
But this declaration is actually not correct as
Vue
object type is declared underVue.default
. This causes the compilation error which I showed above.I already created the PR to fix this bug. Once this is merged, you can use global
Vue
without any additional set up which means we would no longer require this section in docs.vuejs/vue#9912
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.
Yes I think something has changed in latest typescript version that makes this kind of declaration break - I need to investigate more. But if we can make it work in global context without tricks then even better.