From 84ba7937adf9ed2a9c2538a4f93feac481817f00 Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Mon, 5 Dec 2022 14:05:42 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20compiler=20=E2=80=9CType=20'string'=20is?= =?UTF-8?q?=20not=20assignable=20to=20type=20'PluralRuleName'=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I18n.pluralRulesMap keys are variable so “string” wasn’t compatible when the compiler thought we were using fixed string literals Might be worth another look at `Object.keys()` in future with: * https://github.com/microsoft/TypeScript/pull/45464 --- src/govuk/i18n.mjs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/govuk/i18n.mjs b/src/govuk/i18n.mjs index 87b3ebd184..e2635bf9ba 100644 --- a/src/govuk/i18n.mjs +++ b/src/govuk/i18n.mjs @@ -211,7 +211,7 @@ I18n.prototype.selectPluralFormUsingFallbackRules = function (count) { * regardless of region. There are exceptions, however, (e.g. Portuguese) so * this searches by both the full and shortened locale codes, just to be sure. * - * @returns {PluralRuleName | undefined} The name of the pluralisation rule to use (a key for one + * @returns {string | undefined} The name of the pluralisation rule to use (a key for one * of the functions in this.pluralRules) */ I18n.prototype.getPluralRulesForLocale = function () { @@ -262,7 +262,7 @@ I18n.prototype.getPluralRulesForLocale = function () { * Spanish: European Portuguese (pt-PT), Italian (it), Spanish (es) * Welsh: Welsh (cy) * - * @type {Object} + * @type {Object} */ I18n.pluralRulesMap = { arabic: ['ar'], @@ -348,12 +348,6 @@ I18n.pluralRules = { } } -/** - * Supported languages for plural rules - * - * @typedef {'arabic' | 'chinese' | 'french' | 'german' | 'irish' | 'russian' | 'scottish' | 'spanish' | 'welsh'} PluralRuleName - */ - /** * Plural rule category mnemonic tags *