1. 首页
  2. 数据库
  3. 其它
  4. ts pattern:Type完整的TypeScript模式匹配库具有智能类型推断功能 源码

ts pattern:Type完整的TypeScript模式匹配库具有智能类型推断功能 源码

上传者: 2021-02-22 16:36:20上传 ZIP文件 83.46KB 热度 49次
ts模式 具有智能类型推断功能的完整模式匹配库。 import { match } from 'ts-pattern' ; type Data = | { type : 'text' ; content : string } | { type : 'img' ; src : string } | ... ; // Imagine this union is huge! type Result = | { type : 'ok' ; data : Data } | { type : 'error' ; error : Error } ; const result : Res
下载地址
用户评论