-
-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support generated locale type #1890
feat: support generated locale type #1890
Conversation
Looks like the type tests fail, will look into this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Job! ❤️
I always appreciate your PR!
I have tested it locally and your PR works as expected !!
I would mind you to fix two things: 🙏
- change
IntlifyGeneratedTypeConfig
toGeneratedTypeConfig
- export
GeneratedTypeConfig
also inpetite-vue-i18n
pkg.
when you will fix these, we can merge your PR :)
I have implemented your suggestions 💪 Looks like the e2e tests for windows are failing, is this related to the code or flaky? (I can't rerun the action) |
While figuring out
unplugin-vue-router
generates and uses its types I figured a similar approach could be used here.This PR adds the
IntlifyGeneratedTypeConfig
interface which is empty by default, and aGeneratedLocale
type which resolves tonever
ifIntlifyGeneratedTypeConfig['locale']
remains unset. Maybe it should be renamed to justGeneratedTypeConfig
orTypeConfig
🤔I have updated nuxt-modules/i18n#3025 to use this approach, please try it out locally to see if it works for you locally. I'm not very experienced with types like these, just trying to imitate what seems to work for other libraries, maybe there's a better approach?
For reference, the types used in router van uvr:
When this interface is augmented like below, the
Locale
type will resolve to"en" | "en-GB" | "ja" | "fr" | "nl" | "de"
everywhere, leaving the interface empty (no augmentatio) will use the types normally andLocale
resolves tostring
.