Skip to content

Commit

Permalink
[docs] Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gvergnaud committed Mar 29, 2022
1 parent 6829f2c commit d86f4e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ with smart type inference.
</p>

```ts
import { match } from 'ts-pattern';
import { match, P } from 'ts-pattern';

type Data =
| { type: 'text'; content: string }
Expand All @@ -31,9 +31,9 @@ type Result =
const result: Result = ...;

return match(result)
.with({ type: 'error' }, (res) => `<p>Oups! An error occured</p>`)
.with({ type: 'error' }, () => `<p>Oups! An error occured</p>`)
.with({ type: 'ok', data: { type: 'text' } }, (res) => `<p>${res.data.content}</p>`)
.with({ type: 'ok', data: { type: 'img' } }, (res) => `<img src=${res.data.src} />`)
.with({ type: 'ok', data: { type: 'img', src: P.select() } }, (src) => `<img src=${src} />`)
.exhaustive();
```

Expand Down

0 comments on commit d86f4e2

Please sign in to comment.