Skip to content

Commit

Permalink
Fix compiler “Type 'string' is not assignable to type 'PluralRuleName'”
Browse files Browse the repository at this point in the history
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:

* microsoft/TypeScript#45464
  • Loading branch information
colinrotherham committed Dec 19, 2022
1 parent 1da8355 commit b32353a
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/govuk/i18n.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -262,7 +262,7 @@ I18n.prototype.getPluralRulesForLocale = function () {
* Spanish: European Portuguese (pt-PT), Italian (it), Spanish (es)
* Welsh: Welsh (cy)
*
* @type {Object<PluralRuleName, string[]>}
* @type {Object<string, string[]>}
*/
I18n.pluralRulesMap = {
arabic: ['ar'],
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit b32353a

Please sign in to comment.