Code generation for class decorators
Categories
(Core :: JavaScript Engine, enhancement, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox117 | --- | fixed |
People
(Reporter: dminor, Assigned: dminor)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
Code generation for decorators is likely to be complicated, so we'll split it into multiple bugs. This bug covers code generation for class decorators.
Comment 1•2 years ago
|
||
Please note: in the shims and TypeScript experimental support I've seen, the order of class decorators may be backwards, compared to other types of decorators.
Comment 2•2 years ago
|
||
:-) TypeScript 5 nightlies seem to get the ordering of class decorators from top to bottom, rather than from bottom to top as comment 1 shows. I think TS5 has it right.
Comment 3•2 years ago
•
|
||
OK, I really need to apologize, because after a year, I finally understand that decorators running from bottom to top is desirable. The reasoning has to do with the classes they return.
For class decorators which can return a new class, top-to-bottom implies the earliest decorator returns the outermost class:
class C extends B {
}
class B extends A {
}
class A {
}
This would be like:
@C
@B
class A {
}
That's why class decorators run backwards, from bottom to top.
I think the appropriate punishment for so much bug spam is to make me write the class decorators documentation on developer.mozilla.org.
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Comment 4•2 years ago
|
||
We currently synthesize a while loop to process initializers added by decorators, but this
while loop doesn't really have a location in the input source, so we fake it. This adds
a version of WhiteEmitter::Cond that does not take source coordinates to avoid
triggering assertions about the coordinate validity.
Assignee | ||
Comment 5•2 years ago
|
||
Depends on D184147
Updated•2 years ago
|
Comment 7•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/d40ced9b1d57
https://hg.mozilla.org/mozilla-central/rev/b91fdb9d2883
Description
•