infer return type of functions

This commit is contained in:
Thomas Ruoff
2021-03-22 23:14:48 +01:00
parent 3cf2aff832
commit 9fe3fffb86
16 changed files with 54 additions and 54 deletions

View File

@@ -1,11 +1,11 @@
import { MILAGE_TARIFS } from '../db/enums'
import { AdditionalCost } from '../db/bill'
function roundToCent(amount: number) {
function roundToCent(amount: number): number {
return Math.round(amount * 100) / 100
}
export function getMilageCosts(tarif: MILAGE_TARIFS, km: number): number {
export function getMilageCosts({ tarif, km }: { tarif: MILAGE_TARIFS; km: number }): number {
if (tarif === MILAGE_TARIFS.NOCHARGE) {
return 0
}
@@ -56,7 +56,7 @@ export function getBillTotal({
milage?: number
additionalCosts: AdditionalCost[]
}): number {
const milageCosts = getMilageCosts(tarif, milage)
const milageCosts = getMilageCosts({ tarif, km: milage })
const additionalCostsSum = additionalCosts
.map(({ value }) => value)
.reduce((acc: number, value: number) => acc + value, 0)