Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BREAKING: There's a breaking change on how to apply
@signal
to a getter/setter, see below.@signal
decorator descriptors in the same locations as decorated class members to more closely align the object shape with what a user wrote. For example if a field was decorated with@signal
, the signal descriptor will be on the instance, and if an auto or getter/setter accessor was decorated with@signal
then the descriptor will be on the prototype@signal
no longer result in own properties on instances, but result in a prototype property. For example, any checks likeObject.hasOwn(this, 'prop')
for a property namedprop
defined as@signal get prop() {}
will now returnfalse
instead oftrue
. Features likeObject.assign
will no longer work on those properties. Etc. If you need the properties to be own, migrate to using@signal prop
instead of a getter/setter, or update the dependent code to do something else.@signal
fields without a class decorator by defining@signal #finalize
after all fields are defined. For example instead of this,constructor
runs, making it possible to rely on the signal fields insideconstructor
. For example the following will not work when using the@reactive
class decorator approach:@signal #finalize
comes after all class field definitions; any fields that come after@signal #finalize
will not be signalified.It is up to you which form you prefer. If you do not need the signals within
constructor
, you might like the aesthetic look of the@reactive
class decorator more than an unused#finalize
field, or, at an implementation level you might like the purity of the@signal #finalize
approach because it does not make a subclass like@reactive
does.@signal
on getters/setters to work without a class decorator (adding support for#private
getters/setters, but now requiring the@signal
decorator to be placed on both the getter and the setter otherwise it won't work and an error will be shown in console)@reactive
class decorator, but the@signal
decorator must now be placed on both the getter and setter of a property definition:@signal
to your getter/setter so that both are decorated. Optionally delete the@reactive
decorator from your class if you are using the new@signal #finalize
or no fields at all (f.e. only autoaccessor
s).#private
getters/setters:#private
auto accessors. For example, and as an alternative to@reactive
or@signal #finalize
approaches, we can now write "auto accessor" fields:#private
"auto accessor" fields:The main benefit of this update is that we now have a way to apply
@signal
to#private
properties, but note that only auto accessors and getters/setters are supported when it comes to making them#private
, and fields cannot not be private due to the current version of the decorator spec: