fix: pluralization of words ending in y, where y follows a vowel (#10697)
Fixes: FRMW-2851
This commit is contained in:
5
.changeset/unlucky-carpets-remain.md
Normal file
5
.changeset/unlucky-carpets-remain.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/types": patch
|
||||
---
|
||||
|
||||
fix: pluralization of words ending in y, where y follows a vowel
|
||||
@@ -18,6 +18,11 @@ describe("Pluralize", () => {
|
||||
expectTypeOf<Pluralize<"knife">>().toEqualTypeOf<"knives">()
|
||||
})
|
||||
|
||||
test("pluralize words ending with ch", () => {
|
||||
expectTypeOf<Pluralize<"church">>().toEqualTypeOf<"churches">()
|
||||
expectTypeOf<Pluralize<"arch">>().toEqualTypeOf<"arches">()
|
||||
})
|
||||
|
||||
test("pluralize words ending with o", () => {
|
||||
expectTypeOf<Pluralize<"hero">>().toEqualTypeOf<"heroes">()
|
||||
})
|
||||
@@ -30,8 +35,20 @@ describe("Pluralize", () => {
|
||||
expectTypeOf<Pluralize<"fiz">>().toEqualTypeOf<"fizes">()
|
||||
})
|
||||
|
||||
test("pluralize words ending with y", () => {
|
||||
test("pluralize words ending with y, in which y follows a constant", () => {
|
||||
expectTypeOf<Pluralize<"puppy">>().toEqualTypeOf<"puppies">()
|
||||
expectTypeOf<Pluralize<"twenty">>().toEqualTypeOf<"twenties">()
|
||||
expectTypeOf<Pluralize<"copy">>().toEqualTypeOf<"copies">()
|
||||
})
|
||||
|
||||
test("pluralize words ending with y, in which y follow a vowel", () => {
|
||||
expectTypeOf<Pluralize<"play">>().toEqualTypeOf<"plays">()
|
||||
expectTypeOf<Pluralize<"relay">>().toEqualTypeOf<"relays">()
|
||||
expectTypeOf<Pluralize<"alley">>().toEqualTypeOf<"alleys">()
|
||||
expectTypeOf<Pluralize<"alley">>().toEqualTypeOf<"alleys">()
|
||||
expectTypeOf<Pluralize<"boy">>().toEqualTypeOf<"boys">()
|
||||
expectTypeOf<Pluralize<"enjoy">>().toEqualTypeOf<"enjoys">()
|
||||
expectTypeOf<Pluralize<"buy">>().toEqualTypeOf<"buys">()
|
||||
})
|
||||
|
||||
test("pluralize words with special rules", () => {
|
||||
|
||||
@@ -365,26 +365,34 @@ export type Pluralize<Singular extends string> =
|
||||
? PluralizationSpecialRules[Lowercase<Singular>]
|
||||
: Lowercase<Singular> extends UncountableRules
|
||||
? Singular
|
||||
: Singular extends `${infer R}ss`
|
||||
: Singular extends `${string}ss`
|
||||
? `${Singular}es`
|
||||
: Singular extends `${infer R}sis`
|
||||
? `${R}ses`
|
||||
: Singular extends `${infer R}is`
|
||||
? `${R}ises`
|
||||
: Singular extends `${infer R}s`
|
||||
: Singular extends `${string}s`
|
||||
? `${Singular}`
|
||||
: Singular extends `${infer R}ay`
|
||||
? `${R}ays`
|
||||
: Singular extends `${infer R}ey`
|
||||
? `${R}eys`
|
||||
: Singular extends `${infer R}iy`
|
||||
? `${R}iys`
|
||||
: Singular extends `${infer R}oy`
|
||||
? `${R}oys`
|
||||
: Singular extends `${infer R}uy`
|
||||
? `${R}uys`
|
||||
: Singular extends `${infer R}y`
|
||||
? `${R}ies`
|
||||
: Singular extends `${infer R}es`
|
||||
: Singular extends `${string}es`
|
||||
? `${Singular}`
|
||||
: Singular extends
|
||||
| `${infer R}sh`
|
||||
| `${infer R}ch`
|
||||
| `${infer R}x`
|
||||
| `${infer R}z`
|
||||
| `${infer R}o`
|
||||
| `${string}sh`
|
||||
| `${string}ch`
|
||||
| `${string}x`
|
||||
| `${string}z`
|
||||
| `${string}o`
|
||||
? `${Singular}es`
|
||||
: Singular extends `${infer R}fe`
|
||||
? `${R}ves`
|
||||
|
||||
Reference in New Issue
Block a user