Skip to content
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

Refactoring: From Config Classes to Objects #279

Merged
merged 1 commit into from
Oct 18, 2023
Merged

Conversation

rokotyan
Copy link
Contributor

@rokotyan rokotyan commented Sep 22, 2023

Currently Unovis initializes config classes based on the corresponding TypeScript interfaces. There's a big problem with this approach: the default parameters in the class don't automatically inherit types from the interface, making our code more error-prone.

This PR moves away from using classes to using simple objects for component and container configuration. It solves the problem with the types, and it has already pointed out some of the existing bugs in the code.

The main downside of this approach is that it may be a breaking change on the TypeScript side of things, causing TypeScript errors in our users' code.

@rokotyan rokotyan added the enhancement New feature or request label Sep 22, 2023
Copy link
Collaborator

@reb-dev reb-dev left a comment

Choose a reason for hiding this comment

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

@rokotyan The change makes sense, I'm on board with it.

Besides the other comments I posted,

  • Any reason we should keep all of the undefined values in the default configs? It seems like a good chance to clean up the code a little.
  • Stylistically - why not use camel case for the configs. i.e. areaDefaultConfig instead of AreaDefaultConfig? Since they are constants now not classes

packages/ts/src/components/grouped-bar/config.ts Outdated Show resolved Hide resolved
packages/ts/src/components/stacked-bar/config.ts Outdated Show resolved Hide resolved
@rokotyan rokotyan force-pushed the refactor/config-objects branch 3 times, most recently from 99a5ce9 to 856f146 Compare October 2, 2023 20:24
@rokotyan rokotyan force-pushed the refactor/config-objects branch 3 times, most recently from 8e76fdb to a939213 Compare October 17, 2023 01:18
reb-dev
reb-dev previously approved these changes Oct 18, 2023
@rokotyan rokotyan merged commit e207bde into main Oct 18, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants