docs: typescript essential style guide#3389
Conversation
Co-authored-by: Ben Hong <ben@bencodezen.io>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
✅ Deploy Preview for vuejs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
ubugeeei
left a comment
There was a problem hiding this comment.
I left a few comments for now, mainly about the content itself!
As for the overall structure of the documentation, I still have some doubts, so I’d like to discuss that on Discord instead. (My thoughts aren’t fully formed enough yet to leave comments.)
| }>() | ||
| ``` | ||
|
|
||
| In Vue 3.4 and earlier, use `withDefaults()` to declare default values for props. |
There was a problem hiding this comment.
It does depend on the version, but in the Motivation section of the Props Destructure RFC written by Evan, it says:
Succinct and native-like syntax for default values and local alias. Big DX improvement over withDefaults().
So I don’t think we need to intentionally mention withDefaults in the style guide.
It became stable in 3.5, but it should have been possible to opt in even before that.
| ```ts | ||
| const userId = ref(1) | ||
|
|
||
| watch(userId, (id) => loadUser(id), { immediate: true }) |
There was a problem hiding this comment.
This is not the main point, but seeing loadUser may suggest something async.
Combined with watch, it could be interpreted as recommending code that may cause race conditions, so a more motivational example might be better. (For example, opening and closing a dialog)
Previously, there was actually an example like that in the official tutorial, and it caused a bit of discussion.
Co-authored-by: ubugeeei <ubuge1122@gmail.com>
Description of Problem
The original Essential Style Guide was designed for JavaScript. In this PR, we will create a Vue Essential Style Guide specifically for TypeScript.
Proposed Solution
/style-guide/rules-essential-ts.htmlto this guideRelared #3370