diff --git a/src/Models/Denomination.ts b/src/Models/Denomination.ts index 487d36c7a..b3b8f9dd6 100644 --- a/src/Models/Denomination.ts +++ b/src/Models/Denomination.ts @@ -64,7 +64,7 @@ export class Denomination { throw `${context} uses the old 'default'-key. Use "useIfNoUnitGiven" or "useAsDefaultInput" instead` } - const humanTexts = typeof json.human === "string" ? Translations.T(json.human) : new Translation(json.human) + const humanTexts: TypedTranslation<{ quantity: string }> = Translations.T(json.human) humanTexts.OnEveryLanguage((text, language) => { if (text.indexOf("{quantity}") < 0) { throw `In denomination: a human text should contain {quantity} (at ${context}.human.${language}). The offending text is: ${text}` @@ -85,21 +85,6 @@ export class Denomination { ) } - public clone() { - return new Denomination( - this.canonical, - this._canonicalSingular, - this.useIfNoUnitGiven, - this.prefix, - this.addSpace, - this.alternativeDenominations, - this.human, - this.humanSingular, - this.validator, - this.factorToCanonical - ) - } - public withBlankCanonical() { return new Denomination( "", @@ -181,18 +166,17 @@ export class Denomination { } value = value.toLowerCase() - const self = this - function startsWith(key) { - if (self.prefix) { + const startsWith = (key) => { + if (this.prefix) { return value.startsWith(key) } else { return value.endsWith(key) } } - function substr(key) { - if (self.prefix) { + const substr = (key) => { + if (this.prefix) { return value.substring(key.length).trim() } let trimmed = value.substring(0, value.length - key.length).trim()