News for hackers. Stuff that matters.
Re:Migrating from Vue 2 to Svelte by lmiller1990 on Friday December 02, 2022 @12:26AM (#33827153)
Re events - You can type events in Vue with `defineEmits`: https://vuejs.org/api/sfc-script-setup.html#defineprops-defi...

Re global enums - I'm not sure what the author means about global enums - anything imported into your Vue file can be used in the `<template>`.

Re styles - Style is automatically scoped in Vue SFC files, too - I believe it was the first component framework to do this.

This article and migration seems not very thoroughly researched - seems the author just wants a reason to rewrite the front-end.

Re:Migrating from Vue 2 to Svelte by simlevesque on Friday December 02, 2022 @12:28AM (#33827164)
That's my impression too.
Re:Migrating from Vue 2 to Svelte by Elte on Friday December 02, 2022 @12:55AM (#33827320)
I've got a couple of templates where I've aliased the value of a TypeScript enum into a local variable before using it in the template, so I'm pretty certain at that point I was unable to use the value of the enum directly (that's also how I remember it). However, I just tried it and...it seems to just work now. So thanks for making me revisit that :D.
Re:Migrating from Vue 2 to Svelte by Semaphor on Friday December 02, 2022 @12:59AM (#33827336)
I agree with the rest, but how do you use imported TS enums in your template? Something like this being impossible is regularly a pain point for me:

    slotProps.data.type === ArticleTypes.SomeType
Re:Migrating from Vue 2 to Svelte by Pokerkoffer on Friday December 02, 2022 @02:07AM (#33827750)
Store a reference to the enum locally then you can use it in templates
Re:Migrating from Vue 2 to Svelte by Semaphor on Friday December 02, 2022 @02:11AM (#33827771)
Yeah, but that’s an ugly workaround and how I understand what OP was talking about with global enums.
Re:Migrating from Vue 2 to Svelte by trinovantes on Friday December 02, 2022 @02:35AM (#33827882)
`ArticleTypes` should be automatically available in the template just from importing it if you use script setup

Otherwise you also need to return it in the setup function (composition) or store a local copy of it in the data field (options)

Re:Migrating from Vue 2 to Svelte by Semaphor on Friday December 02, 2022 @02:48AM (#33827956)
It… does. Now I wonder if this was not in 3 from the beginning, or if I simply always assumed this behavior was the same after upgrading from Vue2. Wow. Thanks.
Re:Migrating from Vue 2 to Svelte by oefrha on Friday December 02, 2022 @04:24AM (#33828462)
> Style is automatically scoped in Vue SFC files

<style> is global, <style scoped> is scoped. But comparing frameworks based on having to write at most one extra scoped property in each file, or having to wrap HTML template in a <template> is laughable. You get a hundred times the time back the first time you need a library not available in the smaller ecosystem.