Skip to content

Commit ed5312e

Browse files
committed
[docs] Improve one file example
1 parent 5aadc20 commit ed5312e

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

examples/one-file-demo.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ const exampleFunction1 = (input: Response): string =>
5454
**************************************/
5555

5656
type 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

examples/tsconfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true
4+
}
5+
}

src/patterns.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ export function intersection<
161161
* @example
162162
* match(value)
163163
* .with(
164-
* {
165-
* type: P.union('a', 'b', 'c')
166-
* },
164+
* { type: P.union('a', 'b', 'c') },
167165
* ({ user }) => 'will match { type: "a" | "b" | "c" }'
168166
* )
169167
*/

0 commit comments

Comments
 (0)