refactor(ast/estree): expose INCLUDE_TS_FIELDS constant on Serializer#9943
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 21, 2025
Conversation
Member
Author
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. |
This was referenced Mar 21, 2025
CodSpeed Instrumentation Performance ReportMerging #9943 will not alter performanceComparing Summary
|
Member
Author
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
Base automatically changed from
03-21-fix_ast_estree_fix_ts_type_def_for_tsthisparameter_
to
main
March 21, 2025 07:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

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.