money-ts
money-ts copied to clipboard
ExchangeRate types don't match implementation
The type of exchange
is currently
export const exchange = <S extends string, D extends string>(er: ExchangeRate<S, D>) => (d: Dense<S>): Dense<D> => {
return unsafeCoerce(d.mul(unwrap(er)))
}
The problem is that Dense<D>
also carries runtime information for D
. In the implementation above this information is not adapter, so you end up with a value thinking it's Dense<D>
when at runtime it's still Dense<S>
. You can see this in effect when trying to round the resulting Dense<D>
- it will try to look up the target unit under source format's scale table.