Skip to content

Commit 7db1c4c

Browse files
committed
move some types around
1 parent f4dcdcc commit 7db1c4c

File tree

11 files changed

+12
-21
lines changed

11 files changed

+12
-21
lines changed

workshop/01-pure-functions/pure-functions.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Copilot sier:
66
depend on any state, or data, change during a program’s execution. They must only depend on their input arguments."
77
*/
88

9-
import { Currency } from "../constants";
10-
import { Transaction } from "../types";
9+
import { Currency, Transaction } from "../types";
1110

1211
/**
1312
* OPPGAVE 1.1: En enkel pure function

workshop/02-higher-order-functions/__spoilers/dontopen.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Currency } from "../../constants";
2-
import { Transaction } from "../../types";
1+
import { Transaction, Currency } from "../../types";
32

43
export const isCurrency = (currency: Currency, transaction: Transaction) =>
54
transaction.currency === currency;

workshop/02-higher-order-functions/higher-order-functions.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Copilot sier:
55
"Higher order functions are functions that take other functions as arguments or return functions as their results."
66
*/
77

8-
import { Transaction } from "../types";
9-
import { Currency } from "../constants";
8+
import { Transaction, Currency } from "../types";
109

1110
import { isCurrency, nullableProducts } from "./__spoilers/dontopen";
1211

workshop/03-currying-partial-application/__spoilers/dontopen.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Currency } from "../../constants";
2-
import { Transaction } from "../../types";
1+
import { Transaction, Currency } from "../../types";
32

43
export const currencyFilter = (currency: Currency) => {
54
return (transaction: Transaction): boolean =>

workshop/03-currying-partial-application/currying-partial-application.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Copilot sier:
55
"Currying is the process of transforming a function that takes multiple arguments into a function that takes them one at a time."
66
*/
77

8-
import { Transaction } from "../types";
9-
import { Currency } from "../constants";
8+
import { Transaction, Currency } from "../types";
109
import * as ExchangeRates from "../constants";
1110

1211
/**

workshop/04-compose/__spoilers/dontopen.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as ExchangeRates from "../../constants";
22
import { convertCurrency } from "../../03-currying-partial-application/currying-partial-application";
3-
import { Currency } from "../../constants";
4-
import { Transaction } from "../../types";
3+
import { Transaction, Currency } from "../../types";
54

65
export const dkkToSek = convertCurrency(ExchangeRates.DKK_TO_SEK);
76
export const sekToUsd = convertCurrency(ExchangeRates.SEK_TO_USD);

workshop/04-compose/compose.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ Copilot sier:
77

88
import { flow } from "fp-ts/function";
99
import R from "remeda";
10-
import { Currency } from "../constants";
11-
import { Transaction } from "../types";
10+
import { Currency, Transaction } from "../types";
1211
import {
1312
dkkToSek,
1413
sekToUsd,

workshop/05-algebraic-data-types/algebraic-datatypes.ts

-2
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,3 @@ export type Response<T> = ErrorResponse | SuccessResponse<T>;
4646
export function handleResponse(response: Response<string>): string {
4747
return "";
4848
}
49-
50-
// TODO compose chain kombinert med unions?

workshop/constants.ts

-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ export let SEK_TO_USD = 0.094;
33
export let USD_TO_GBP = 0.82;
44
export let GBP_TO_EUR = 1.13;
55
export let EUR_TO_NOK = 11.28;
6-
7-
export type Currency = "EUR" | "NOK" | "SEK" | "DKK" | "USD" | "GBP";

workshop/transactions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Transaction } from "../utils/createMockData";
1+
import { Transaction } from "./types";
22

33
export const transactions: Transaction[] = [
44
{

workshop/types.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
export type Currency = "EUR" | "NOK" | "SEK" | "DKK" | "USD" | "GBP";
2+
13
type TransactionType = "withdrawal" | "deposit" | "salary" | "invoice" | "payment";
24

35
export type Transaction = {
4-
currency: string;
6+
currency: Currency;
57
time: string;
68
amount: number;
79
product?: string;
810
merchantCountry?: string;
911
merchantName?: string;
1012
transactionType: TransactionType;
11-
};
13+
};

0 commit comments

Comments
 (0)