Skip to content

Commit 9bc6610

Browse files
committed
update docusaurus
1 parent 575ab1b commit 9bc6610

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

website/src/pages/index.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,19 @@ Key benefits:
289289
- Helps catch type mismatches at compile time while preserving narrowed inferred types.
290290

291291
```ts
292+
// Array constant
293+
type UserRole = 'admin' | 'editor' | 'moderator' | 'viewer' | 'guest';
294+
295+
// ❌ Avoid constant of wide type
296+
const DASHBOARD_ACCESS_ROLES: ReadonlyArray<UserRole> = ['admin', 'editor', 'moderator'];
297+
298+
// ❌ Avoid constant with incorrect values
299+
const DASHBOARD_ACCESS_ROLES = ['admin', 'contributor', 'analyst'] as const;
300+
301+
// ✅ Use immutable constant of narrowed type
302+
const DASHBOARD_ACCESS_ROLES = ['admin', 'editor', 'moderator'] as const satisfies ReadonlyArray<UserRole>;
303+
304+
// Object constant
292305
type OrderStatus = {
293306
pending: 'pending' | 'idle';
294307
fulfilled: boolean;

0 commit comments

Comments
 (0)