francescov1 / mongoose-tsgen

A plug-n-play Typescript generator for Mongoose.
102 stars 24 forks source link

Plurals to singular are still not handled clearly #156

Closed CdTgr closed 1 month ago

CdTgr commented 1 month ago

Relating to the issue 79 and the PR #82, the plurals for some of them are corrected, but not all plurals ends with sses.

I got this issue when I was using the key capabilities where the types generated is as capabilitie but the actual singular is capability

Also some of the other plurals are completely different as well.

eg:

francescov1 commented 1 month ago

good catch, ies -> y is probably a safe assumption to make for most english words so can be easily added. the rest are a bit harder. maybe there's a library that handles converting between singulars and plurals?

CdTgr commented 1 month ago

Yes I too think so. A simple string replacement would not be sufficient for a language.

Probably inflection would do. The only down I see there is that this one has a lot of dependencies, but there might be something else with lesser dependencies.

It might also work, maybe with some tree shaking.

francescov1 commented 1 month ago

plurazile looks ideal, no dependencies, just a lot of custom rules. Maybe not as good as something like inflection but much more light weight. Thoughts?

CdTgr commented 1 month ago

Yes it looks so nice and small. But the downside I see in it is that the package was last updated 5years ago. Either there is nothing to update in between or might be stale. But the package itself looks solid, if there is something that's not covered in the package, it can always be replaced with another one.

But I still assume there might be some specific items missing from the package as I see its also using some kind of mapping.

francescov1 commented 1 month ago

agreed. There's some newer ones but theyre much less popular. Lets give this one a go, and can swap it out later if there's any major issues. Looking at the list of open issues and PRs, it looks like a lot of very niche edge cases, so sounds like the main ones are handled

francescov1 commented 1 month ago

Fix is live in v9.4.1 🚀

CdTgr commented 1 month ago

Thanks a lot for the quick fixes and the knowledgeable conversation ❤️