首页 > 解决方案 > 打字稿将数字类型转换为从不

问题描述

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;没有任何改变......

标签: javascripttypescriptreact-nativeexpo

解决方案


推荐阅读