-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Do not incorrectly add line separators for non-synthetic nodes when emitting node list #44070
Do not incorrectly add line separators for non-synthetic nodes when emitting node list #44070
Conversation
44944a2
to
3c884e4
Compare
@@ -35,7 +35,8 @@ var y = { | |||
"typeof": | |||
}; | |||
var x = (_a = { | |||
a: a, : .b, | |||
a: a, | |||
: .b, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewer: It looks like these baseline changes are due to us no longer checking if previous and next nodes (when emitting the node list) are on the same line if either one does not have a parent set. We only check if nodes are on the same line if they have the same parent container.
It looks like the logic for checking if there is a parent set has been introduced as part of the following refactoring (not sure if this was intentional; or if it's reasonable to continue doing that). 68b0323.
3c884e4
to
8e55aa0
Compare
src/compiler/emitter.ts
Outdated
else if (siblingNodePositionsAreComparable(previousNode, nextNode)) { | ||
if (preserveSourceNewlines) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid incurring a performance penalty during normal program emit (i.e., via tsc
), siblingNodePositionsAreComparable
must not be called unless preserveSourceNewlines
is true (which only happens in the language service for determining changes for codefixes and refactors).
@typescript-bot perf test this — I know I made this code path cheaper than it used to be, but I think we still want to avoid it during regular emit. |
Heya @andrewbranch, I've started to run the perf test suite on this PR at 8e55aa0. You can monitor the build here. Update: The results are in! |
@andrewbranch Here they are:Comparison Report - master..44070
System
Hosts
Scenarios
Developer Information: |
Hm, that actually seems ok. |
f0097f8
to
cb7bb0f
Compare
@andrewbranch Thanks for reviewing. I've updated the logic to never call Also I've explicitly added the fallback case for |
…mitting node list As of 3c32f6e, a line separator is added between nodes if the nodes are not synthetic and on separate lines. This it push s wrong and previously only happened if the non-synthetic nodes were on different lines but had the same parent. Fixes microsoft#44068.
cb7bb0f
to
d192080
Compare
…t regression Updates the compiler-cli compliance goldens. The golden updates are required due to a regression in TypeScript 4.3 that causes the emitter to not incorrectly preserve lines when emitting a node list. This can be reverted once microsoft/TypeScript#44070 is available.
…t regression Updates the compiler-cli compliance goldens. The golden updates are required due to a regression in TypeScript 4.3 that causes the emitter to not incorrectly preserve lines when emitting a node list. This can be reverted once microsoft/TypeScript#44070 is available.
@typescript-bot perf test this |
Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at d192080. You can monitor the build here. |
@rbuckton can you take a quick look? @typescript-bot perf test this |
Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at d192080. You can monitor the build here. Update: The results are in! |
@DanielRosenwasser Here they are:Comparison Report - master..44070
System
Hosts
Scenarios
Developer Information: |
Here's what I'm thinking after chatting a bit with @andrewbranch: emit changes are hard a little bit risky. I think it's probably okay to bring this into our |
@DanielRosenwasser Makes sense to me. |
@typescript-bot cherry-pick this to release-4.3 |
Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into |
Hey @DanielRosenwasser, I've opened #44187 for you. |
Component commits: d192080 Do not incorrectly add line separators for non-synthetic nodes when emitting node list As of 3c32f6e, a line separator is added between nodes if the nodes are not synthetic and on separate lines. This it push s wrong and previously only happened if the non-synthetic nodes were on different lines but had the same parent. Fixes microsoft#44068.
@DanielRosenwasser this is ready to go, right? From reading your comment, it sounds like we want to get this into the nightlies as soon as possible in order to decide whether to publish a 4.3 patch. |
…t regression Updates the compiler-cli compliance goldens. The golden updates are required due to a regression in TypeScript 4.3 that causes the emitter to not incorrectly preserve lines when emitting a node list. This can be reverted once microsoft/TypeScript#44070 is available.
…t regression Updates the compiler-cli compliance goldens. The golden updates are required due to a regression in TypeScript 4.3 that causes the emitter to not incorrectly preserve lines when emitting a node list. This can be reverted once microsoft/TypeScript#44070 is available.
@DanielRosenwasser @sandersn Is there any update on this change? It would be great to see this change in the nightly builds, given it being a change that could be considered a regression (at least in perspective of the printer as it preserves non-existent lines between list items as of TS 4.3). |
Let’s do it 👍 |
…t regression (#42022) Updates the compiler-cli compliance goldens. The golden updates are required due to a regression in TypeScript 4.3 that causes the emitter to not incorrectly preserve lines when emitting a node list. This can be reverted once microsoft/TypeScript#44070 is available. PR Close #42022
Component commits: d192080 Do not incorrectly add line separators for non-synthetic nodes when emitting node list As of 3c32f6e, a line separator is added between nodes if the nodes are not synthetic and on separate lines. This it push s wrong and previously only happened if the non-synthetic nodes were on different lines but had the same parent. Fixes #44068. Co-authored-by: Paul Gschwendtner <[email protected]>
Updates to TypeScript 4.3.4 which contains a fix for a printer regression that caused unexpected JavaScript output with our compiler transforms. See: microsoft/TypeScript#44070.
Updates to TypeScript 4.3.4 which contains a fix for a printer regression that caused unexpected JavaScript output with our compiler transforms. See: microsoft/TypeScript#44070.
Updates to TypeScript 4.3.4 which contains a fix for a printer regression that caused unexpected JavaScript output with our compiler transforms. See: microsoft/TypeScript#44070. Updates to TypeScript 4.3.4 which contains a fix for a printer
Updates to TypeScript 4.3.4 which contains a fix for a printer regression that caused unexpected JavaScript output with our compiler transforms. See: microsoft/TypeScript#44070. Updates to TypeScript 4.3.4 which contains a fix for a printer PR Close #42600
…t regression (angular#42022) Updates the compiler-cli compliance goldens. The golden updates are required due to a regression in TypeScript 4.3 that causes the emitter to not incorrectly preserve lines when emitting a node list. This can be reverted once microsoft/TypeScript#44070 is available. PR Close angular#42022
As of 3c32f6e, a line separator is added between nodes if the nodes are
not synthetic and on separate lines. This is wrong and previously only
happened if the non-synthetic nodes were on different lines but had the same parent.
Fixes #44068.