-
Notifications
You must be signed in to change notification settings - Fork 12.9k
fix(42605): support refactoring for export default assignment without equal #42936
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
Conversation
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
0eef449
to
7d96672
Compare
What are the parser and checker changes for? |
|
I mean, I’m asking how that’s different from the current behavior. |
this changes is for refactoring. currently select |
Right. My point is, changing the behavior of a refactor usually doesn’t require changing the parser or checker, and conversely, changing the parser and checker will usually have a much broader impact than changing the behavior of a refactor. Clearly we already parse and check |
@andrewbranch Thanks for your patience and advice, I finally understand what you mean. The codebase has changed since this PR created, and I find there is no need to change checker any more, but the parser seems still need change, here is the reason: TypeScript/src/services/refactors/convertExport.ts Lines 108 to 111 in 4d50624
For It should be noted that |
Ah, yes. So, this is a weird part of our parse tree, but I think it’s working as intended. We parse |
src/compiler/utilities.ts
Outdated
@@ -4720,7 +4720,7 @@ namespace ts { | |||
* NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc. | |||
*/ | |||
export function getSyntacticModifierFlagsNoCache(node: Node): ModifierFlags { | |||
let flags = modifiersToFlags(node.modifiers); | |||
let flags = (isExportAssignment(node) && !node.isExportEquals) ? ModifierFlags.None : modifiersToFlags(node.modifiers); |
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.
We should handle this, or the Convert default export to named export
options will be disabled.
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.
Doesn’t modifiersToFlags
already return None
in this case?
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.
Fixed, same mistake #42936 (comment)
As you suggested, I have updated my PR, please help review it again. |
d3a2556
to
4e358e7
Compare
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.
Sorry, GitHub was having some issues yesterday and it looks like these two comments didn’t make it through.
src/compiler/utilities.ts
Outdated
@@ -4720,7 +4720,7 @@ namespace ts { | |||
* NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc. | |||
*/ | |||
export function getSyntacticModifierFlagsNoCache(node: Node): ModifierFlags { | |||
let flags = modifiersToFlags(node.modifiers); | |||
let flags = (isExportAssignment(node) && !node.isExportEquals) ? ModifierFlags.None : modifiersToFlags(node.modifiers); |
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.
Doesn’t modifiersToFlags
already return None
in this case?
4e358e7
to
1f85cbc
Compare
1f85cbc
to
7629184
Compare
Convert default export to named export
refactoring…
Thanks for review, I have updated this PR again, ready for new round review. |
just friendly ping |
Fixes #42605
The original issue pointed that
Convert default export to named export
refactoring is not available when it has specific format below.export default () => {}
I can confirm the first situation is a bug, since we support
export default function foo () {}
refactoring currently.But for second situation, I think it may be a feature not a bug, because
export default function() {}
is also not supported, and I traced the original relevant PR, this situation is not supported at very beginning.So I just fix the bug part, as for feature part, I am not quite sure.