Skip to content

fix parsing displayName for components defined using function expression #516

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

radnan
Copy link

@radnan radnan commented Jun 11, 2025

regression from #449

displayName for functions that are defined using function expression are no longer working correctly

not familiar enough with the codebase to figure out the actual problem - but for now this fix will work if you have only one function expression in the file - but will break in the edge case where you have more than one function expression components - probly related to how function components are resolved from some other change

@pvasek
Copy link
Collaborator

pvasek commented Jun 12, 2025

Could you give me an example of a file that would fail? I am surprised we don't have it in our test suite.

Did these multiple function expressions in the single file ever work?

@@ -1023,6 +1023,16 @@ describe('parser', () => {
assert.equal(parsed.displayName, 'StatelessDisplayName');
});

it('should be taken from stateless component `displayName` property (using named export and function expression)', () => {
Copy link
Author

@radnan radnan Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you give me an example of a file that would fail? I am surprised we don't have it in our test suite.

Did these multiple function expressions in the single file ever work?

@pvasek

added a test to showcase how existing behavior is broken - it's not really related to exporting single or multiple components (you really shouldn't be exporting multiple components in same file in the first place 😛 )

rather just that if you use traditional function expression instead of arrow expression the computeComponentName is no longer working because of the additional flowNodeNameEscapedText check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants