我在使用gRPC-web,我有来自服务器的id类型number|Long的数据。我需要将number|Long分配给number。Long来自使用gRPC进行通信的服务器。
错误:
Type 'number | Long' is not assignable to type 'number'. Type 'Long' is not assignable to type 'number'. 当我尝试parseInt()时,它说:
Type 'number' is not assignable to type 'string'发布于 2021-03-21 18:19:07
长到数字是一种有损的操作,因此您无法在没有任何精度损失的情况下安全地完成它。但是有一个.toNumber()方法可以使用。
https://stackoverflow.com/questions/66735679
复制相似问题