Skip to content

Commit 8cce53e

Browse files
committed
docs: performance notes of messages augmentation
1 parent c323050 commit 8cce53e

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

docs/src/pages/docs/workflows/typescript.mdx

+43-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,49 @@ declare module 'next-intl' {
122122

123123
You can freely define the interface, but if you have your messages available locally, it can be helpful to automatically create the type based on the messages from your default locale.
124124

125-
### Strict arguments [#messages-arguments]
125+
<Details id="messages-performance-tsc">
126+
<summary>Does this affect the performance of type checking?</summary>
127+
128+
While the size of your messages file can have an effect on the time it takes to run the TypeScript compiler on your project, the overhead of augmenting `Messages` should be reasonably fast.
129+
130+
Here's a benchmark from a sample project with 340 messages:
131+
132+
- No type augmentation for messages: ~2.20s
133+
- Type-safe keys: ~2.82s
134+
- Type-safe arguments: ~2.85s
135+
136+
This was observed on a MacBook Pro 2019 (Intel).
137+
138+
---
139+
140+
If you experience performance issues on larger projects, you can consider:
141+
142+
1. Using type augmentation of messages only on your continuous integration pipeline as a safety net
143+
2. Splitting your project into multiple packages in a monorepo, allowing you to work with separate messages per package
144+
145+
</Details>
146+
147+
<Details id="messages-performance-editor">
148+
<summary>Does this affect the performance of my editor?</summary>
149+
150+
Generally, type augmentation for `Messages` should be [reasonably fast](#messages-performance-tsc).
151+
152+
In case you notice your editor performance related to saving files to be impacted, it might be caused by running ESLint on save when using [type-aware](https://typescript-eslint.io/troubleshooting/typed-linting/performance/) rules from `@typescript-eslint`.
153+
154+
To ensure your editor performance is optimal, you can consider running expensive, type-aware rules only on your continuous integration pipeline:
155+
156+
```tsx filename="eslint.config.js"
157+
// ...
158+
159+
// Run expensive, type-aware linting only on CI
160+
'@typescript-eslint/no-misused-promises': process.env.CI
161+
? 'error'
162+
: 'off'
163+
```
164+
165+
</Details>
166+
167+
### Type-safe arguments [#messages-arguments]
126168

127169
Apart from strictly typing message keys, you can also ensure type safety for message arguments:
128170

0 commit comments

Comments
 (0)