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
149149
150150``` ts
151151// ❌ Avoid optional properties as they increase complexity
152- type StatusParams = {
152+ type User = {
153153 id? : number ;
154154 email? : string ;
155155 dashboardAccess? : boolean ;
@@ -184,6 +184,15 @@ type GuestUser = {
184184
185185// Discriminated union type 'User' with no optional properties
186186type 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+ };
187196```
188197
189198### Discriminated union
You can’t perform that action at this time.
0 commit comments