Skip to content

Commit 4d2a7b8

Browse files
committed
update docusaurus
1 parent f8dd021 commit 4d2a7b8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

website/src/pages/index.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,13 @@ Consider the advantages of explicitly defining the return type of a function::
637637
638638
Strive declaring constants using const assertion `as const`:
639639
640-
- Type Narrowing - Using as const narrows the type of literals to their exact values rather than general types.
640+
Constants are used to represent values that are not meant to change, ensuring reliability and consistency in a codebase. Using const assertions further enhances type safety and immutability, making your code more robust and predictable.
641+
642+
- Type Narrowing - Using `as const` ensures that literal values (e.g., numbers, strings) are treated as exact values instead of generalized types like `number` or `string`.
641643
- Immutability - Objects and arrays get readonly properties, preventing accidental mutations.
642644
645+
- Objects
646+
643647
```ts
644648
// ❌ Avoid
645649
const FOO_LOCATION = { x: 50, y: 130 }; // Type { x: number; y: number; }
@@ -650,6 +654,8 @@ Strive declaring constants using const assertion `as const`:
650654
FOO_LOCATION.x = 10; // Error
651655
```
652656
657+
- Arrays
658+
653659
```ts
654660
// ❌ Avoid
655661
const BAR_LOCATION = [50, 130]; // Type number[]
@@ -660,6 +666,8 @@ Strive declaring constants using const assertion `as const`:
660666
BAR_LOCATION.push(10); // Error
661667
```
662668
669+
- Template Literals
670+
663671
```ts
664672
// ❌ Avoid
665673
const RATE_LIMIT = 25;

0 commit comments

Comments
 (0)