File tree 1 file changed +0
-23
lines changed
1 file changed +0
-23
lines changed Original file line number Diff line number Diff line change @@ -144,29 +144,6 @@ src/
144
144
validation.ts
145
145
```
146
146
147
- ## 6. Consolidate Linting and Formatting at the Root Level
148
-
149
- Define linting and formatting configurations once at the root level to ensure consistency and simplify maintenance.
150
-
151
- ## 7. Prefer Compile-Time Validation Over Runtime Checks
152
-
153
- Leverage compile-time validation by defining robust type systems, rather than relying heavily on runtime checks. Example:
154
-
155
- ``` typescript
156
- type AdminUser = { kind: ' admin' ; id: string ; permissions: string [] };
157
- type RegularUser = { kind: ' regular' ; id: string };
158
-
159
- type User = AdminUser | RegularUser ;
160
-
161
- function handleUser(user : User ) {
162
- if (user .kind === ' admin' ) {
163
- // Admin logic
164
- } else {
165
- // regular user logic
166
- }
167
- }
168
- ```
169
-
170
147
## 7. Type-Driven Development
171
148
172
149
Use comprehensive, precise types to enforce correctness at compile-time rather than relying on runtime validation.
You can’t perform that action at this time.
0 commit comments