You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat!: Disallow passing null, undefined or boolean as an ICU argument (#1561)
These are errors now:
```tsx
t('message', {value: null});
t('message', {value: undefined});
t('message', {value: false});
```
If you really want to put a raw boolean value in a message, you can cast
it to a string first:
```tsx
const value = true;
t('message', {value: String(value)});
```
(the types in these examples are slightly simplified, e.g. a date can also be provided as a timestamp)
140
-
141
139
With this type inference in place, you can now use autocompletion in your IDE to get suggestions for the available arguments of a given ICU message and catch potential errors early.
142
140
141
+
This also addresses one of my favorite pet peeves:
142
+
143
+
```tsx
144
+
t('followers', {count: 30000});
145
+
```
146
+
147
+
```json
148
+
// ✖️ Would be: "30000 followers"
149
+
"{count} followers"
150
+
151
+
// ✅ Valid: "30,000 followers"
152
+
"{count, number} followers"
153
+
```
154
+
143
155
Due to a current limitation in TypeScript, this feature is opt-in for now. Please refer to the [strict arguments](/docs/workflows/typescript#messages-arguments) docs to learn how to enable it.
144
156
145
157
## GDPR compliance
@@ -211,9 +223,10 @@ If things go well, I think this will finally fill in the [missing piece](https:/
211
223
2. Inherit context in case nested `NextIntlClientProvider` instances are present (see [PR #1413](https://github.com/amannn/next-intl/pull/1413))
212
224
3. Automatically inherit formats when `NextIntlClientProvider` is rendered from a Server Component (see [PR #1191](https://github.com/amannn/next-intl/pull/1191))
213
225
4. Require locale to be returned from `getRequestConfig` (see [PR #1486](https://github.com/amannn/next-intl/pull/1486))
214
-
5. Bump minimum required typescript version to 5 for projects using TypeScript (see [PR #1481](https://github.com/amannn/next-intl/pull/1481))
215
-
6. Remove deprecated APIs (see [PR #1479](https://github.com/amannn/next-intl/pull/1479))
216
-
7. Remove deprecated APIs pt. 2 (see [PR #1482](https://github.com/amannn/next-intl/pull/1482))
226
+
5. Disallow passing `null`, `undefined` or `boolean` as an ICU argument (see [PR #1561](https://github.com/amannn/next-intl/pull/1561))
227
+
6. Bump minimum required typescript version to 5 for projects using TypeScript (see [PR #1481](https://github.com/amannn/next-intl/pull/1481))
228
+
7. Remove deprecated APIs (see [PR #1479](https://github.com/amannn/next-intl/pull/1479))
229
+
8. Remove deprecated APIs pt. 2 (see [PR #1482](https://github.com/amannn/next-intl/pull/1482))
0 commit comments