Comments (5)
呃,#12 不用重新打开,那个是我试了下 github 的在线编辑功能,还挺好使的。
因为 GuardLevel 导出时用的是 export type
,所以不会编译到 js 里,GuardLevel 这个变量实际上不存在于 dist/index.js
中。
类型上是没问题,但是当作数据来用的话会出问题,比如 identity.guard_level === GuardLevel.Zongdu
。
from blive-message-listener.
另外,定义了 enum 但只导出它的 type 这个行为其实也不太好,包的使用者还得自己再定义遍 enum
from blive-message-listener.
感谢指出!我看 #12 被 Close 了没有合并,需要重新打开么?
另外,定义了 enum 但只导出它的 type 这个行为其实也不太好,包的使用者还得自己再定义遍 enum
在我个人使用来看,是通过 import type { GuardLevel } from 'blive-message-listener'
就可以导入并使用的,似乎不用重新定义?
from blive-message-listener.
v0.3.1 已修正;
枚举在 JavaScript 环境使用的话似乎没想到什么方案(枚举改为导出 Object?)目前我的想法还是 TS 用枚举 JS 用 number 判断
from blive-message-listener.
v0.3.1 已修正; 枚举在 JavaScript 环境使用的话似乎没想到什么方案(枚举改为导出 Object?)目前我的想法还是 TS 用枚举 JS 用 number 判断
🤔
就正常编译到 es5 成 object 就行,tsc 把 enum 编译成 object 后,类型上还是 enum。
目前这种情况 TS 开发环境下也用不了枚举,因为 import 出来的只有类型,必须手动重新定义一个同样的 enum。
或者可以转一遍数据变成字符串的版本:
export type GuardLevel = 'None' | 'ZongDu' | 'TiDu' | 'JianZhang'
from blive-message-listener.
Related Issues (19)
- 可以用 npm 引入吗? HOT 3
- 浏览器中使用的问题 HOT 2
- 2022/11/30: 弹幕消息更新了【bili-ws[msg(DANMU_MSG:4:0:2:2:2:0)]】 HOT 5
- 是否有字段或方法可以获取直播间信息? HOT 2
- `parent_area_name` 和 `area_name` 是否是应该为 `string` 类型呢? HOT 1
- 过滤重复的舰长进入直播间消息
- 是否无法支持短房号? HOT 4
- emoji表情 HOT 4
- [FEATURE] 完善更多常用事件 HOT 3
- Electron 和 Vue3开发打包的时候会出现报错 HOT 2
- 调用close方法时,会触发两次onClose HOT 1
- add `/browser` test file HOT 1
- 监听弹幕时获取用户头像 HOT 3
- electron preload 中 exposeInMainWorld 使用该库报错 HOT 2
- 实测 Message.id 还是有不唯一的情况 HOT 1
- Browser environment support
- Large amount of danmu freshes when the liver draws a lottery HOT 1
- 关于关闭 TCP 连接 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blive-message-listener.