@@ -7,18 +7,18 @@ with smart type inference.
77
88<p align =" center " >
99 <a href =" https://www.npmjs.com/package/ts-pattern " >
10- <img src="https://img.shields.io/npm/dm/ts-pattern.svg" alt="downloads per month " height="18">
10+ <img src="https://img.shields.io/npm/dm/ts-pattern.svg" alt="downloads" height="18">
1111 </a >
1212 <a href =" https://www.npmjs.com/package/ts-pattern " >
1313 <img src="https://img.shields.io/npm/v/ts-pattern.svg" alt="npm version" height="18">
1414 </a >
1515 <a href =" https://github.com/gvergnaud/ts-pattern " >
16- <img src="https://img.shields.io/npm/l/ts-pattern.svg" alt="license" height="18">
16+ <img src="https://img.shields.io/npm/l/ts-pattern.svg" alt="MIT license" height="18">
1717 </a >
1818</p >
1919
2020``` ts
21- import { match } from ' ts-pattern' ;
21+ import { match , P } from ' ts-pattern' ;
2222
2323type Data =
2424 | { type: ' text' ; content: string }
@@ -31,9 +31,9 @@ type Result =
3131const result: Result = ... ;
3232
3333return match (result )
34- .with ({ type: ' error' }, (res ) => ` <p>Oups! An error occured</p> ` )
34+ .with ({ type: ' error' }, () => ` <p>Oups! An error occured</p> ` )
3535 .with ({ type: ' ok' , data: { type: ' text' } }, (res ) => ` <p>${res .data .content }</p> ` )
36- .with ({ type: ' ok' , data: { type: ' img' } }, (res ) => ` <img src=${res . data . src } /> ` )
36+ .with ({ type: ' ok' , data: { type: ' img' , src: P . select () } }, (src ) => ` <img src=${src } /> ` )
3737 .exhaustive ();
3838```
3939
0 commit comments