safe-units
safe-units copied to clipboard
Make Basis type parameters type-safe
I've based this PR on #207 so that I can actually make sure that all of the tests pass. Merge that before reviewing this. Once you've done that, you may need to push a commit that merges the main branch into this one in order to make the commit from that PR disappear from this one. You have my permission to do that (I've checked "Allow edits by maintainers").
Before, the type system would let you pass in anything as a basis, even things that weren't objects. Now, Basis types must conform to the type Record<string, string> (aliased as BasisType, with a doc comment).
I had to change how the errorBasis test works (it's simpler now).
I would start your review with measure/unitSystem.ts.
This will be a breaking change for anyone wrapping Measure.