-
-
Notifications
You must be signed in to change notification settings - Fork 247
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!: Revamp augmented types and add support for typed Locale
#1495
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Locale
Locale
Hey @dBianchii, as part of the upcoming v4 release of Since this is closely related to PR #1346 that you've worked on, I was wondering if you're curious to have a look? The PR description has the relevant details. If you're up for it, would be cool if you could have a look at the updated TypeScript docs page to see if this sounds reasonable to you. I was honestly a bit surprised that the strict typing of The PR is pretty much ready to go from my perspective, but I need to give it another look tomorrow—my head is already spinning a bit from the type wrestling today 😄. Would be curious if you have an opinion here! |
I'm waiting for that so much, great pr! 🙂 |
Hi @amannn, awesome! I'll try to take a look either today or tomorrow. Can't really promise it as I am quite busy, so please don't wait for me for release. Thanks! |
@dBianchii No worries, only if you have the time! The feature will be part of the upcoming v4 version, that will first have to go through a beta/RC phase—so no stress at all.
Yep, I also did something similar like this before in projects: export const locales = ["en", "pt-BR"] as const;
export type Locale = (typeof locales)[number]; (or based on This can be used in userland-code, but the difference now is that Also, you can start with |
Really great! Feels good being able to just import the type of Excited for v4 and for Next.JS 15 support 🎉 |
@dBianchii Awesome, thanks a lot for having a look! 🙌 |
Note that all entries in
AppConfig
are optional and can be added as necessary—if at all.Features
next-intl
.import {Locale} from 'next-intl';
as a convenience API to be used wherever alocale
is passed around (example).hasLocale(locales: Array<Locale>, candidate: string): candidate is Locale
API for simplified checking of whether a locale matches a given list of locales while also correctly narrowing the type (example).import {Messages} from 'next-intl;
type that corresponds to theMessages
you've provided inAppConfig
(probably rarely needed).Breaking changes
IntlMessages
andIntlFormats
in favor of a more generalAppConfig
that is scoped tonext-intl
.→ Proposed docs
Resolves #1377