File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -635,14 +635,14 @@ Consider the advantages of explicitly defining the return type of a function::
635635
636636### Const Assertion
637637
638- Strive to use const assertion ` as const ` :
638+ Strive declaring constants using const assertion ` as const ` :
639639
640640- type is narrowed
641641- object gets ` readonly ` properties
642642- array becomes ` readonly ` tuple
643643
644644 ` ` ` ts
645- // ❌ Avoid declaring constants without const assertion
645+ // ❌ Avoid
646646 const FOO_LOCATION = { x: 50 , y: 130 }; // Type { x: number; y: number; }
647647 FOO_LOCATION .x = 10 ;
648648
@@ -652,7 +652,7 @@ Strive to use const assertion `as const`:
652652 const RATE_LIMIT = 25 ;
653653 const RATE_LIMIT_MESSAGE = ` Max number of requests/min is ${RATE_LIMIT }. ` ; // Type string
654654
655- // ✅ Use const assertion
655+ // ✅ Use
656656 const FOO_LOCATION = { x: 50 , y: 130 } as const ; // Type '{ readonly x: 50; readonly y: 130; }'
657657 FOO_LOCATION .x = 10 ; // Error
658658
You can’t perform that action at this time.
0 commit comments