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

feat: added snippets for defineEmits, defineProps, withDefaults macros #132

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ These snippets are meant to provide a base scaffold for your single file compone
| `v3watch-array` | Vue Composition API - watch as array |
| `v3watcheffect` | Vue Composition API - watchEffect |
| `v3ref` | Vue Ref |
| `v3emits-ts` | Vue Composition API - defineEmits macros with TS |
| `v3props-ts` | Vue Composition API - defineProps macros with TS |
| `v3withdefaults-ts` | Vue Composition API - withDefaults macros with TS |
| `v3onmounted` | Lifecycle hook - onMounted |
| `v3onbeforemount` | Lifecycle hook - onBeforeMount |
| `v3onbeforeupdate` | Lifecycle hook - onBeforeUpdate |
Expand Down
35 changes: 35 additions & 0 deletions snippets/vue-script.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,41 @@
"body": ["const ${1:name} = ref(${2:initialValue})"],
"description": "Vue Ref"
},
"Vue Composition API - defineEmits": {
"prefix": "v3emits-ts",
"body": [
"interface IEmits {",
"\t(e: '${1:name}'): ${2}",
"}",
"",
"const emit = defineEmits<IEmits>()"
],
"description": "Vue Composition api - defineEmits with Typescript"
},
"Vue Composition API - defineProps": {
"prefix": "v3props-ts",
"body": [
"interface IProps {",
"\t${1:name}: ${2}",
"}",
"",
"const prop = defineProps<IProps>()"
],
"description": "Vue Composition api - defineProps with Typescript"
},
"Vue Composition API - withDefaults": {
"prefix": "v3withdefaults-ts",
"body": [
"interface IProps {",
"\t${1:name}: ${2}",
"}",
"",
"const props = withDefaults(defineProps<IProps>(), {",
"\t${1:name}: ${3},",
"})"
],
"description": "Vue Composition api - withDefaults props with Typescript"
},
"Vue Lifecycle Hooks - onMounted": {
"prefix": "v3onmounted",
"body": ["onMounted(() => {${1}})"],
Expand Down