feat: support generated locale type #1890
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.