fix(42605): support refactoring for export default assignment without equal#42936
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 |
| */ | ||
| 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.
We should handle this, or the Convert default export to named export options will be disabled.
There was a problem hiding this comment.
Doesn’t modifiersToFlags already return None in this case?
As you suggested, I have updated my PR, please help review it again. |
d3a2556 to
4e358e7
Compare
andrewbranch
left a comment
There was a problem hiding this comment.
Sorry, GitHub was having some issues yesterday and it looks like these two comments didn’t make it through.
| */ | ||
| 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.
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 exportrefactoring 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.