| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) perf test |
Sorry, something went wrong.
|
Heya Ron Buckton (@rbuckton), I've started to run the diff-based user code test suite on this PR at b3487dc. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Ron Buckton (@rbuckton), I've started to run the parallelized Definitely Typed test suite on this PR at b3487dc. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Ron Buckton (@rbuckton), I've started to run the extended test suite on this PR at b3487dc. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Ron Buckton (@rbuckton), I've started to run the perf test suite on this PR at b3487dc. You can monitor the build here. |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) perf test |
Sorry, something went wrong.
|
Heya Ron Buckton (@rbuckton), I've started to run the perf test suite on this PR at a37f09a. You can monitor the build here. Update: The results are in! |
Sorry, something went wrong.
|
Ron Buckton (@rbuckton) Comparison Report - main..49705
System
Hosts
Scenarios
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) run dt |
Sorry, something went wrong.
|
Heya Ron Buckton (@rbuckton), I've started to run the parallelized Definitely Typed test suite on this PR at 54024cf. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Ron Buckton (@rbuckton), I've started to run the diff-based user code test suite on this PR at 54024cf. You can monitor the build here. Update: The results are in! |
Sorry, something went wrong.
|
Heya Ron Buckton (@rbuckton), I've started to run the extended test suite on this PR at 54024cf. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Ron Buckton (@rbuckton), I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
Sorry, something went wrong.
|
Ron Buckton (@rbuckton) |
Sorry, something went wrong.
|
Why is this a thing? Like, what problem does it actually solve (genuine question, not snark)? The generated accessors don't do anything and unlike, e.g., C#, changing a plain property to an accessor isn't generally an API break... edit: Oh, I see, it's mostly because decorators will apparently make a distinction between field and accessor. |
Sorry, something went wrong.
This was a requirement from VM implementers to avoid the potential hidden shape changes that could occur if you were able to convert a field declaration into an accessor dynamically rather than statically. It also helps to avoid issues with public field shadowing in cases like the following, such as with @observe in #48814: class C {
// observe attaches an accessor pair to C.prototype, but the field `x` is defined
// on the instance, shadowing the accessor pair.
@observe x = 1;
}
// vs
class C {
// observe can now instead intercept the `{ get, set }` provided to attach its behavior.
@observe accessor x = 1;
} |
Sorry, something went wrong.
|
What are the assignability rules for auto-accessor fields? I guess that they're the same as a normal class field, but might be missing something. |
Sorry, something went wrong.
|
They should be treated the same as we would a get/set pair. |
Sorry, something went wrong.
|
Ah, that explains why the code in the checker is with the existing accessor code, not the property declaration code. |
Sorry, something went wrong.
|
Very naive question: EDIT: I guess the keyword for readonly properties would be readonly :) class C {
readonly x = 1;
}
into class C {
#x_accessor_storage = 1;
get x() { return this.#x_accessor_storage; }
}
But that would be a very breaking change; which could be enabled by a --strictReadonly flag in the compiler options... Which would be a lot of work just for syntactic sugar |
Sorry, something went wrong.
More generally, is there a reason that readonly accessor isn't supported? |
Sorry, something went wrong.
It's not currently supported because the accessor isn't actually read-only (a setter is still generated) and that might break user expectations. Also, support for actual read-only accessors is planned as part of https://github.com/tc39/proposal-grouped-and-auto-accessors, which is blocked on any advancement until after Decorators reaches Stage 4. With the full auto-accessors proposal, you could accomplish a true read-only accessor using the following syntax: class C {
accessor x { get; } = 1;
}Which would transform into something like this: class C {
#x_accessor_storage = 1;
get x() { return this.#x_accessor_storage; }
} |
Sorry, something went wrong.
|
Actually having a readonly accessor x; would be lovely to just generate the public getter ❤️ |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR adds support for accessor field declarations described in the Stage 3 Decorators proposal.
An Auto-Accessor is a field declaration that will be transformed by the runtime into a pair of get and set accessors that access a private backing field:
When you use --target ESNext, accessor fields will be left as is to be transformed by the runtime. Any earlier --target will result in TypeScript downleveling the accessor field to a compatible runtime implementation.
Auto-Accessor fields have several capabilities:
In addition, there are several rules around the use of the accessor keyword:
NOTE: This is not an implementation of the full Stage 3 Decorators proposal as that effort is still in progress.