@@ -54,21 +54,21 @@ const exampleFunction1 = (input: Response): string =>
5454 **************************************/
5555
5656type UserType = 'editor' | 'viewer' ;
57- // Uncomment 'premium ' to see exhaustive checking in action
58- type OrgPlan = 'basic' | 'pro' /* | 'premium' * / | 'enterprise' ;
57+ // Uncomment 'enterprise ' to see exhaustive checking in action
58+ type OrgPlan = 'basic' | 'pro' | 'premium' ; / / | 'enterprise';
5959
60- const exampleFunction2 = ( org : OrgPlan , user : UserType ) : string =>
60+ const exampleFunction2 = ( org : OrgPlan , user : UserType ) =>
6161 // 1. Checking several enums with tuples
6262 match ( [ org , user ] as const )
6363 . with ( [ 'basic' , P . _ ] , ( ) => `Please upgrade to unlock this feature!` )
6464 // 2. `.with()` can take several patterns. It will match if one of them do.
6565 . with (
6666 [ 'pro' , 'viewer' ] ,
67- [ 'enterprise ' , 'viewer' ] ,
67+ [ 'premium ' , 'viewer' ] ,
6868 ( ) => `Your account doesn't have permissions to use this feature`
6969 )
7070 . with ( [ 'pro' , 'editor' ] , ( ) => `Hello!` )
71- . with ( [ 'enterprise ' , 'editor' ] , ( ) => `You are our favorite customer!` )
71+ . with ( [ 'premium ' , 'editor' ] , ( ) => `You are our favorite customer!` )
7272 // 3. complex exhaustive checking
7373 . exhaustive ( ) ;
7474
0 commit comments