opensearch-project / oui

OpenSearch UI Framework
Apache License 2.0
33 stars 69 forks source link

Fix anonymous class error in docsite #1181

Open BSFishy opened 9 months ago

BSFishy commented 9 months ago

With PR #1104, building the docsite fails because of this line:

https://github.com/opensearch-project/oui/blob/a17c839b6102b16619b7bff6ba94b328a99db836/src-docs/src/views/comment/comment_actions.tsx#L38

The issue is that the proptypes-from-ts-props Babel plugin doesn't support anonymous classes. There are a few ways that I can think to resolve this:

  1. Refactor the component to a functional component. This shouldn't be too much effort and could be considered a modernization effort.
  2. Filter the plugin so it doesn't run on docsite files. The plugin is really just to make sure proptypes are generated for source components, so it doesn't make much sense that it's running on the docsite. Granted, this doesn't really fix anything, just suppresses it.
  3. Give the class a name. This is a pretty quick and simple fix, but doesn't account for if this crops up in the future. Granted, if we only accept functional components in the future, this shouldn't be an issue.
  4. Add support for this in the Babel plugin. This may require gaining some knowledge about that plugin, which seems quite large and complex, so my mind doesn't immediately run to this one.

I put these in order of what I would prefer, but I want to get more opinions on this.

ShatilKhan commented 9 months ago

@BSFishy Should I try refactoring it to a functional component? Just to test it out...

BSFishy commented 9 months ago

I believe @AMoo-Miki was doing some investigation around this. @AMoo-Miki do you have an update?