-
-
Notifications
You must be signed in to change notification settings - Fork 755
refactor(ast/estree): expose INCLUDE_TS_FIELDS constant on Serializer
#9943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(ast/estree): expose INCLUDE_TS_FIELDS constant on Serializer
#9943
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Instrumentation Performance ReportMerging #9943 will not alter performanceComparing Summary
|
Merge activity
|
…zer` (#9943) Remove the `serialize_ts_element` method added in #9913, and instead expose an `INCLUDE_TS_FIELDS` constant on `Serializer` trait. Before: ```rs if let Some(this_param) = &self.0.this_param { seq.serialize_ts_element(this_param); } ``` After: ```rs if S::INCLUDE_TS_FIELDS { if let Some(this_param) = &self.0.this_param { seq.serialize_element(this_param); } } ``` This has one slight advantage. Because `INCLUDE_TS_FIELDS` is a constant, compiler will easily be able to prove that the code inside `if S::INCLUDE_TS_FIELDS { ... }` is dead code in the JS-only AST serializer, and remove it. In this specific case, the TS-only logic is trivial, so compiler would probably see it could be optimized out anyway. But we may encounter other cases where more complex TS-only code is required, and compiler might not be able to prove that it's dead code in those cases.
d587d45 to
9d1035e
Compare
14b2ebc to
dc3e725
Compare

Remove the
serialize_ts_elementmethod added in #9913, and instead expose anINCLUDE_TS_FIELDSconstant onSerializertrait.Before:
After:
This has one slight advantage. Because
INCLUDE_TS_FIELDSis a constant, compiler will easily be able to prove that the code insideif S::INCLUDE_TS_FIELDS { ... }is dead code in the JS-only AST serializer, and remove it.In this specific case, the TS-only logic is trivial, so compiler would probably see it could be optimized out anyway. But we may encounter other cases where more complex TS-only code is required, and compiler might not be able to prove that it's dead code in those cases.