-
-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Type-safe ICU arguments (#1499)
```json { "UserProfile": { "title": "Hello {firstName}" } } ``` ```tsx function UserProfile({user}) { const t = useTranslations('UserProfile'); // ✖️ Missing argument t('title'); // ✅ Argument is provided t('title', {firstName: user.firstName}); } ``` **Changes** - ICU arguments can now be validated with TypeScript (however, currently this is [opt-in](https://next-intl-docs-git-feat-type-safe-params-next-intl.vercel.app/docs/workflows/typescript#messages-arguments)) - `undefined` and `null` are no longer accepted as values for calls to `t`—please only provide valid values. Fixes #410
- Loading branch information
Showing
50 changed files
with
1,328 additions
and
815 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import {locales} from '@/config'; | ||
import en from './messages/en.json'; | ||
import messages from './messages/en.json'; | ||
|
||
declare module 'next-intl' { | ||
interface AppConfig { | ||
Locale: (typeof locales)[number]; | ||
Messages: typeof en; | ||
Messages: typeof messages; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import {routing} from '@/i18n/routing'; | ||
import en from './messages/en.json'; | ||
import messages from './messages/en.json'; | ||
|
||
declare module 'next-intl' { | ||
interface AppConfig { | ||
Locale: (typeof routing.locales)[number]; | ||
Messages: typeof en; | ||
Messages: typeof messages; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ tsconfig.tsbuildinfo | |
*storybook.log | ||
storybook-static | ||
test-results | ||
messages/*.d.json.ts |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import {getPresets} from 'eslint-config-molindo'; | ||
import globals from 'globals'; | ||
|
||
export default await getPresets('typescript', 'react', 'jest'); | ||
export default (await getPresets('typescript', 'react', 'jest')).concat({ | ||
languageOptions: { | ||
globals: globals.node | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import {formats} from '@/i18n/request'; | ||
import {routing} from '@/i18n/routing'; | ||
import en from './messages/en.json'; | ||
import messages from './messages/en.json'; | ||
|
||
declare module 'next-intl' { | ||
interface AppConfig { | ||
Locale: (typeof routing.locales)[number]; | ||
Formats: typeof formats; | ||
Messages: typeof en; | ||
Messages: typeof messages; | ||
} | ||
} |
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.