From 6b1357d5c09ae15b4490d096ff929f3c77f3ab52 Mon Sep 17 00:00:00 2001 From: Maks Pchelnikov Date: Thu, 19 Dec 2024 19:05:45 +0300 Subject: [PATCH] feat: added snippets for defineEmits, defineProps, withDefaults macros --- README.md | 3 +++ snippets/vue-script.json | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/README.md b/README.md index b71ff08..e894744 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/snippets/vue-script.json b/snippets/vue-script.json index 2abfffe..e79469a 100644 --- a/snippets/vue-script.json +++ b/snippets/vue-script.json @@ -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()" + ], + "description": "Vue Composition api - defineEmits with Typescript" + }, + "Vue Composition API - defineProps": { + "prefix": "v3props-ts", + "body": [ + "interface IProps {", + "\t${1:name}: ${2}", + "}", + "", + "const prop = defineProps()" + ], + "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(), {", + "\t${1:name}: ${3},", + "})" + ], + "description": "Vue Composition api - withDefaults props with Typescript" + }, "Vue Lifecycle Hooks - onMounted": { "prefix": "v3onmounted", "body": ["onMounted(() => {${1}})"],