javascript - 打字稿将数字类型转换为从不
问题描述
r = Math.floor(Math.random() * arrOfCourse.length) + 1;
if (arr.indexOf(r) === -1) arr.push(r);
我在 r 上收到此错误Argument of type 'number' is not assignable to parameter of type 'never'.
我想投r
?如果我尝试这样做:
r:any = Math.floor(Math.random() * arrOfCourse.length) + 1;
没有任何改变......
解决方案
推荐阅读
- java - 检查不同的arraylists中是否有重复的数字
- c++ - Google Kickstart 2020 Round A 错误答案:我的代码有什么问题?
- firebase - 不断添加和删除监听器
- symfony - 如何使用 Symfony 在我的控制器中提供来自 HttpClient 的相同响应?
- vba - Shaperange(1) 与 Shaperange() 不安全性
- python - Python忽略条件语句
- c# - iText 7 如何在变量中显示数据?
- typescript - 在带有 docker-compose 和 typescript monorepo 的 docker 容器中使用 babel 意外令牌“导出”
- angularjs - AngularJS:传递承诺,但无法读取未定义的“最终”属性
- ksqldb - KSQL - 从结构数组中选择列作为数组