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

Configuration Improvements #188

Open
mbklein opened this issue Mar 15, 2024 · 0 comments
Open

Configuration Improvements #188

mbklein opened this issue Mar 15, 2024 · 0 comments

Comments

@mbklein
Copy link
Member

mbklein commented Mar 15, 2024

Expanding on this comment:

I think there are two major improvements that can be made to the configuration immediately and relatively easily.

The first is to make all properties of the ViewerConfigOptions type required, and create a second ViewerConstructorOptions that includes the optional and overloaded versions. As an example, ViewerConfigOptions would have:

{
  informationPanel: {
    vtt: {
      autoScroll: AutoScrollOptions
    }
  }
}

while ViewerConstructorOptions would have:

{
  informationPanel?: {
    vtt?: {
      autoScroll?: AutoScrollOptions | AutoScrollSettings | boolean
    }
  }
}

That would preserve the overloaded behavior offered to the consumer, while removing the need for a massive amount of ?. chaining and typecasting throughout the rest of the code. The Constructor version would be coerced into the standard Config version on init, and it would always reliably be there.

The other thing, which goes hand in hand with that one, would be to take any configuration provided by the consumer and deep merge it with the default configuration instead of relying on the consumer to pass in a full config or making every piece of a code that uses a particular option have its own guards.

These two changes would greatly simplify the project as a whole, and make type checking more reliable for both internal components and consumers.

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

No branches or pull requests

1 participant