opaque type library:@ iadvize ossopaque type Typescript的不透明类型 源码

上传:qqhurt33188 浏览: 29 推荐: 0 文件:ZIP 大小:108.48KB 上传时间:2021-04-25 15:44:09 版权申诉
@ iadvize / opaque-types 灵感来自 用法 npm add @iadvize-oss/opaque-type 为什么 ? 语义类型检查 以下纯真代码将正确编译,不同之处在于,如果混合使用createRoom参数,则会在运行时引入讨厌的错误。 type RoomID = string ; type UserID = string ; function createRoom ( roomId : RoomID , userId : UserID ) { // something } const roomId : RoomID = ... ; const userId : UserID = ... ; createRoom ( userId , roomId ) ; 不透明的救援! 以下代码将无法编译,因为Opaque为RoomId和UserId增加了更多的
上传资源
用户评论