File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ If introduction of many optional properties truly can't be avoided utilize **dis
149
149
150
150
``` ts
151
151
// ❌ Avoid optional properties as they increase complexity
152
- type StatusParams = {
152
+ type User = {
153
153
id? : number ;
154
154
email? : string ;
155
155
dashboardAccess? : boolean ;
@@ -184,6 +184,15 @@ type GuestUser = {
184
184
185
185
// Discriminated union type 'User' with no optional properties
186
186
type User = AdminUser | RegularUser | GuestUser ;
187
+
188
+ const regularUser: User = {
189
+ role: ' regular' ,
190
+ id: 212 ,
191
+
192
+ subscriptionPlan: ' pro' ,
193
+ rewardsPoints: 1500 ,
194
+ dashboardAccess: false , // Error 'dashboardAccess' property does not exist
195
+ };
187
196
```
188
197
189
198
### Discriminated union
You can’t perform that action at this time.
0 commit comments