Skip to content

Commit 7db1963

Browse files
committed
Fixed ConvertedCurrency/ConvertedAmount
1 parent d501664 commit 7db1963

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/01-branded-types/05-currency-conversion.solution.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface User {
77
maxConversionAmount: number;
88
}
99

10-
type ConvertedCurrency = Brand<number, "ConvertedCurrency">;
10+
type ConvertedAmount = Brand<number, "ConvertedAmount">;
1111
type AuthorizedUser = Brand<User, "CurrencyAuthorizedUser">;
1212

1313
// Mocks a function that uses an API to convert
@@ -17,19 +17,19 @@ const getConversionRateFromApi = async (
1717
from: string,
1818
to: string,
1919
) => {
20-
return Promise.resolve((amount * 0.82) as ConvertedCurrency);
20+
return Promise.resolve((amount * 0.82) as ConvertedAmount);
2121
};
2222

2323
// Mocks a function which actually performs the conversion
2424
const performConversion = async (
2525
user: AuthorizedUser,
2626
to: string,
27-
amount: ConvertedCurrency,
27+
amount: ConvertedAmount,
2828
) => {};
2929

3030
const ensureUserCanConvert = (
3131
user: User,
32-
amount: ConvertedCurrency,
32+
amount: ConvertedAmount,
3333
): AuthorizedUser => {
3434
if (user.maxConversionAmount < amount) {
3535
throw new Error("User cannot convert currency");

0 commit comments

Comments
 (0)