jkomoros / CASsim

Complex Adaptive Systems Simulator
Apache License 2.0
21 stars 0 forks source link

Auto-generate SimOptions config for each simulator #73

Closed jkomoros closed 2 years ago

jkomoros commented 2 years ago

Currently creators of a simulator have to generate both their SIMULATORSimOptions typescript type and their optionsConfig, and keep them in sync.

Ideally we'd have some tooling that would inspect the optionsConfig and then generate a SIMULATORSimOptions type, keeping hte optionsConfig canonical.

Then we could generate a file in simulators/types/SIMULATORNAME.ts for each one.

Then the SimOptions type can be a discrimnated union, where we include the proper simoptions type for each Simulator.

The optionsConfig is not necessarily JSON (it can include other constants, and like e.g. a hide() function). We'd probably need to swap in a temporary any typed SimOptions, and then load up the files, extract the values, and then it should be pretty simple to declaratively generate a Typescript type based on the options config.

See also #71

jkomoros commented 2 years ago
jkomoros commented 2 years ago

72 uses these schemas

jkomoros commented 2 years ago

In branch auto-generate-simulator-types

jkomoros commented 2 years ago

All remaining issues now tracked in sub issues