←back to thread

277 points merqurio | 1 comments | | HN request time: 0s | source
Show context
epolanski ◴[] No.45113064[source]
Great project but I can't stand syntax such as decorators.
replies(5): >>45113194 #>>45113315 #>>45113317 #>>45113613 #>>45114400 #
jfagnani ◴[] No.45113317[source]
Decorators are the only way to metaprogram over class fields in JS. Otherwise they're not even detectable on the prototype.

We use them to make fields reactive mostly, and I love how declarative they are. But we use them sparingly. I personally don't love how some libraries try to put a lot of things into decorators that could have been standard class features, like a static field or a method.

edit: As mentioned by skrebbel, decorators are optional. Every decorator has a simple plain-JS way of doing it. Event reactive properties: https://lit.dev/docs/components/properties/#declaring-proper...

We also put a lot of effort into making all of our documentation and playground samples on lit.dev available in both JavaScript and TypeScript with decorators. There's a switch that will change everything on the site from JS to TS globally.

replies(2): >>45113690 #>>45114413 #
1. brazukadev ◴[] No.45114413[source]
> Decorators are the only way to metaprogram over class fields in JS.

No, they are not. Decorators don't even exist in JavaScript. Stop assuming typescript is Javascript or even worse, that everybody is on board.

> There's a switch that will change everything on the site from JS to TS globally.

Lol.