friendly-snippets icon indicating copy to clipboard operation
friendly-snippets copied to clipboard

Error in VueJS defineEmitsTS snippet

Open Haerezis opened this issue 7 months ago • 0 comments

Hello,

Maybe i'm mistaken but it seems to me like there's an error in the snippet defineEmitsTS.

Currently, you have :

      "const ${1:emit} = defineEmits<{",
      "\t(e: '${2:event}', ${3:id}: ${4:type}: ${5:type}) ",
      "\t$0",
      "}>()"

The problem is the ": ${5:type}" :

  • it's not TS syntactically correct
  • the official VueJS doc doesn't reference any syntax like this one (https://vuejs.org/guide/typescript/composition-api#typing-component-emits)

the line should be IMO like this :

      "\t(e: '${2:event}', ${3:id}: ${4:type}): void ",

I've removed the incorrect portion, and added a ": void" to complete the function signature (if not, typescript throw a 7020 error) for an implicit "any" return type)

Thanks in advance !

Haerezis avatar Jul 08 '24 08:07 Haerezis