Skip to content

Refactoring: From Config Classes to Objects - #279

Merged
rokotyan merged 1 commit into
mainfrom
refactor/config-objects
Oct 18, 2023
Merged

rokotyan merged 1 commit into
mainfrom
refactor/config-objects

Conversation

@rokotyan

@rokotyan rokotyan commented Sep 22, 2023 •

Copy link
Copy Markdown
Contributor

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 requested a review from reb-dev September 22, 2023 21:13
@rokotyan rokotyan added the enhancement New feature or request label Sep 22, 2023

@reb-dev reb-dev left a comment •

Copy link
Copy Markdown
Contributor

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

Comment thread packages/ts/src/components/grouped-bar/config.ts Outdated
Comment thread packages/ts/src/components/stacked-bar/config.ts Outdated
@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
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