-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Revamp augmented types and add support for typed
Locale
(#1495)
**Changes** - Revamps the API to augment types by getting rid of the global `IntlMessages` and `IntlFormats` in favor of a more general `AppConfig` that is scoped to `next-intl`. - Adds support for strictly-typing the locale across `useLocale` as well as the navigation APIs. - Adds `import {Locale} from 'next-intl';` as a convenience API to be reused wherever a `locale` is passed around. - Add `hasLocale(locales, candidate)` API for simplified checking of whether a locale is available with TypeScript. - Adds a new `import {Messages} from 'next-intl;` type that corresponds to the `Messages` you've provided in `AppConfig` (probably rarely needed). **Example:** ```tsx // global.d.ts import {routing} from '@/i18n/routing'; import {formats} from '@/i18n/request'; import en from './messages/en.json'; declare module 'next-intl' { interface AppConfig { Locale: (typeof routing.locales)[number]; Formats: typeof formats; Messages: typeof en; } } ``` **→ [Proposed docs](https://next-intl-docs-git-feat-augmented-config-next-intl.vercel.app/docs/workflows/typescript)** Fixes #1377
- Loading branch information
Showing
96 changed files
with
979 additions
and
578 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.