-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
Fix moving comments of removed nodes #15427
Merged
nicolo-ribaudo
merged 5 commits into
babel:main
from
nicolo-ribaudo:comments-after-removal
Mar 30, 2023
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5948063
Fix moving comments of removed nodes
nicolo-ribaudo e260f1f
Update other fixtures
nicolo-ribaudo fb76e44
Remove comment
nicolo-ribaudo af1d8a9
Restore behavior of class props comments
nicolo-ribaudo 47f4793
Update fixtures
nicolo-ribaudo File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
17 changes: 17 additions & 0 deletions
17
packages/babel-plugin-transform-typescript/test/fixtures/exports/issue-9916-1/input.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @module | ||
*/ | ||
|
||
import '../message-bus'; | ||
|
||
/** | ||
* @typedef {Function} PromiseResolveCb | ||
*/ | ||
export type PromiseResolveCb<T> = (value?: T | PromiseLike<T>) => void; | ||
|
||
/** | ||
* @typedef {Function} PromiseRejectCb | ||
*/ | ||
export type PromiseRejectCb = (reason?: any) => void; | ||
|
||
var a; |
15 changes: 15 additions & 0 deletions
15
packages/babel-plugin-transform-typescript/test/fixtures/exports/issue-9916-1/output.mjs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* @module | ||
*/ | ||
|
||
import '../message-bus'; | ||
|
||
/** | ||
* @typedef {Function} PromiseResolveCb | ||
*/ | ||
|
||
/** | ||
* @typedef {Function} PromiseRejectCb | ||
*/ | ||
|
||
var a; |
15 changes: 15 additions & 0 deletions
15
packages/babel-plugin-transform-typescript/test/fixtures/exports/issue-9916-2/input.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* @module | ||
*/ | ||
|
||
import '../message-bus'; | ||
|
||
/** | ||
* @typedef {Function} PromiseResolveCb | ||
*/ | ||
export type PromiseResolveCb<T> = (value?: T | PromiseLike<T>) => void; | ||
|
||
/** | ||
* @typedef {Function} PromiseRejectCb | ||
*/ | ||
export type PromiseRejectCb = (reason?: any) => void; |
13 changes: 13 additions & 0 deletions
13
packages/babel-plugin-transform-typescript/test/fixtures/exports/issue-9916-2/output.mjs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* @module | ||
*/ | ||
|
||
import '../message-bus'; | ||
|
||
/** | ||
* @typedef {Function} PromiseResolveCb | ||
*/ | ||
|
||
/** | ||
* @typedef {Function} PromiseRejectCb | ||
*/ |
15 changes: 15 additions & 0 deletions
15
packages/babel-plugin-transform-typescript/test/fixtures/exports/issue-9916-3/input.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* @module | ||
*/ | ||
|
||
/** | ||
* @typedef {Function} PromiseResolveCb | ||
*/ | ||
export type PromiseResolveCb<T> = (value?: T | PromiseLike<T>) => void; | ||
|
||
/** | ||
* @typedef {Function} PromiseRejectCb | ||
*/ | ||
export type PromiseRejectCb = (reason?: any) => void; | ||
|
||
var a; |
14 changes: 14 additions & 0 deletions
14
packages/babel-plugin-transform-typescript/test/fixtures/exports/issue-9916-3/output.mjs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @module | ||
*/ | ||
|
||
/** | ||
* @typedef {Function} PromiseResolveCb | ||
*/ | ||
|
||
/** | ||
* @typedef {Function} PromiseRejectCb | ||
*/ | ||
|
||
var a; | ||
export {}; |
This file contains 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
This file contains 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
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.
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.
IMO in this case the old behaviour is more preferable,
/* before b */
is more likely to be the JSDoc comment of class propertyb
.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.
What do you think should be the priority? When we remove node B from ABC, we first try to attach B's trailing comments as leading comments of C, and then fallback to trailing comments of A?
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.
Ok actually, the priority I implemented is already like that.
What's happening here is that when we have this code:
we call
path.remove()
onstatic b
, and thus its comments are attached toconstructor() {}
which is the only available sibling node.I'm confused by the previous output, because
after b
was attached to the constructor butbefore b
wasn't 🤔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.
I pushed a solution, I'm not sure I like it. The behavior I was confused about was because of the helpers for class fields to inherit comments that we recently introduced.