While it is possible to generically divide any unit by any other unit and get a new unit that works for conversion, it is not possible to get the type of the new unit because we don't know which quantity it should get. To solve that UnitTimes and UnitDivide exists and they support dividing certain units by other units, and returning a correctly typed unit in the resulting quantity.
However it is still not possible to have a generic Amount.divide or Amount.times.
This might be solvable by using conditional types in typescript. Something like:
While it is possible to generically divide any unit by any other unit and get a new unit that works for conversion, it is not possible to get the type of the new unit because we don't know which quantity it should get. To solve that
UnitTimes
andUnitDivide
exists and they support dividing certain units by other units, and returning a correctly typed unit in the resulting quantity.However it is still not possible to have a generic Amount.divide or Amount.times.
This might be solvable by using conditional types in typescript. Something like: