tc39 / proposal-decorators

Decorators for ES6 classes
https://arai-a.github.io/ecma262-compare/?pr=2417
2.77k stars 106 forks source link

List of frameworks using decorators #181

Closed zenparsing closed 10 months ago

zenparsing commented 6 years ago

Is there a list of JS frameworks that are currently providing decorators or documenting usage with decorators?

littledan commented 6 years ago

Not that I know of. This sounds like a good idea for documentation, if anyone is interested in making a PR.

hax commented 5 years ago

Yeah actually I asked someone where is the use cases of changing placement except @bound (actually a sound implementation of @bound not change placement but add extras), and he said I should ask the champions of decorators and none of his business.

littledan commented 5 years ago

Another change of placement between "instance" and "own" is the @observed/@tracked decorator, e.g., as Glimmer has. I don't have a good use case for switching between static and instance-related, though. If there's some particular reason to lock that down, I'd be open to it. Right now, in general, decorators let you replace any class element with any other, so it's not clear exactly how to describe the limitation.

hax commented 5 years ago

@littledan Have no idea about "instance". The document only have "static", "prototype" or "own"...

Let me guess... for PrivateName?

littledan commented 5 years ago

The current spec uses prototype/own, but I am wondering if unifying this as instance could be more intuitive for decorators authors. But, this is a bit off-topic, I just need to make progress on that change and propose it elsewhere.

hax commented 5 years ago

Ah? You mean replace prototype by instance ? Don't understand...

littledan commented 5 years ago

@hax Yes, replace both prototype and own by instance, and say public methods are on the prototype and fields are own (just like in syntax). I don't think the current "generality" actually buys us anything, and is just confusing. See discussion at https://github.com/tc39/proposal-decorators/issues/180#issuecomment-446876704 (yes, it does tie in with private).

hax commented 5 years ago

@littledan Sorry it's not easy for me to understand what #180 for. But it seems now we can not change the placement of own/prototype? And as you said, there is also no use case of change placement of static/non-static, so we can just drop the placement (maybe only provide isStatic)?

littledan commented 5 years ago

@hax Yeah, sorry, #180 is not very clear; I'll get back with a PR that has a clearer commit message. I'd rather use a string value than a boolean just for readability and future extensibility. My thinking is: If you want to make a prototype field, you could use a static initializer/"starter" for it; if you want to make an own method, you can use a field for that. The current design is a bit redundant, causing extra complexity both for JS developers and engine implementers.

hax commented 5 years ago

@littledan Actually I never think change fundamental semantic is a good usage of decorator, so I think it's great.

for readability and future extensibility

Is there anything we want to add in future?

littledan commented 5 years ago

There are lots of things we might want to add in the future. See the v2 label in this repo.

hax commented 5 years ago

@littledan Do you mean "follow-on proposal" label? I made a glance at the list, but do not have the idea which one will add new placement value.

littledan commented 5 years ago

Sorry, yes, that label. And I misunderstood, I thought you meant follow-on proposals in general. I don't have any ideas for other placements, but this is a general "best practice" in JavaScript API design. e.g., see https://w3ctag.github.io/design-principles/#string-constants

hax commented 5 years ago

@littledan I understand this rule prefer string over enum (integers), prefer dictionaries over bitmask. So not directly apply to our case

I prefer static: true | false because many novice do not use instance, just use object 😂 , and most programmers never know what is placement (actually I misspell it several times 😅), but everyone know static because it's a keyword. So static: true | false is a much easy API to learn, especially for those non-English programmers.

littledan commented 5 years ago

You like static better than isStatic? (Me too.)

hax commented 5 years ago

isStatic is ok, but it seems static follows name convention? isStatic more like a method name I think.

ljharb commented 5 years ago

If we have a “static” boolean, would it be an error to specify both that and “placement”? Or, how would “instance” be specified?

hax commented 5 years ago

@ljharb It seems @littledan means do not allow change placement so we can only provide information use boolean. Maybe I misunderstand @littledan ?

littledan commented 5 years ago

I think the idea would be that static replaces placement.

ljharb commented 5 years ago

Is there a separate thread to discuss this? This one is about listing frameworks that use decorators; i'd love to discuss whether it's a good idea to restrict placement options, but i don't want to derail this thread.

pabloalmunia commented 5 years ago

Is there a list of JS frameworks that are currently providing decorators or documenting usage with decorators?

We are working into a very powerful framework with decoratos: https://chameleon.origami.works/

A list about this kind of frameworks and libraries is a very good idea.

kt3k commented 5 years ago

We've been creating DOM programming library which uses decorators for binding methods to events, binding query selectors to fields etc. https://github.com/capsidjs/capsid

Our decorators now conform to babel 7.1+'s new decorator implementation.

littledan commented 5 years ago

In the Stage 3 presentation for TC39 in a week, I'd like to include:

If someone could compile this list, it would be really helpful.

isidrok commented 5 years ago

Here's a list of the frameworks/libraries I can think of off the top of my head, most of them if not all use TS decorators that can be used with the babel plugin in legacy mode:

And here is a list of packages depending on @babel/plugin-proposal-decorators more extensive than the npm one.

this project seems quite interesting and supports both proposals.

littledan commented 5 years ago

@isidrok Thanks! I've copied this list into our draft presentation for TC39.

Lodin commented 5 years ago

I would like to add my framework to this list as well. Still WIP, but I believe not for a long time. Corpuscule

littledan commented 5 years ago

Added Corpuscle.

hax commented 5 years ago

It seems many libraries still use the legacy decorator proposal.

buschtoens commented 5 years ago

@hax https://github.com/tc39/proposal-decorators#how-should-i-use-decorators-in-transpilers-today

glen-84 commented 4 years ago

I started a publicly-editable Google spreadsheet – List of frameworks/libraries using decorators.

I added the following to those previously mentioned:

Feel free to add others (just keep the formatting the same).

pzuraq commented 10 months ago

We are past the information gathering stage that this issue was opened for, so I'm going to close it for the time being. If we need additional information about modern framework usage, we can reopen.