首页 > 其他分享 >Property ‘includes’ does not exist on type ‘any[]’.

Property ‘includes’ does not exist on type ‘any[]’.

时间:2023-10-11 16:24:40浏览次数:38  
标签:arr includes does exist type any

原文链接:https://www.longkui.site/error/property-includes-does-not-exist-on-type-any/4833/

angular项目,TypeScript。

项目正常跑的时候没有问题,打包项目(package)的时候开始报这个错误。

然后定位到代码发现下面这样一段代码

if (this.arr.includes(index)

不同的人的代码可能不一样,但是问题的原因基本一致,问题就出在这个arr上。

这个地方arr是个全局变量,定义的时候是这样定义的

arr=[]

这样确实没什么问题,但是TypeScript会报错,提示不存在”includes“,解决方法也很简单。我们只要把arr数组的类型改变一下就可以了

arr:any=[]

这样的话,我们就可以正常打包了

标签:arr,includes,does,exist,type,any
From: https://www.cnblogs.com/longkui-site/p/17757461.html

相关文章

  • eclipase项目导入错误Some projects cannot be imported because they already exist
    根本原因:workplace和工程名冲突解决办法:1.新建一个目录,打开工程选择该路径 2.导入实际工程得路径位置 ......
  • SQLSugar中Includes和Mapper的区别
    在SQLSugar中,Include和Mapper确实在处理过滤器方面有一些不同的行为。Include方法:当你使用Include方法来加载关联实体时,SQLSugar会忽略过滤器,不会将过滤器应用于加载的关联实体。这意味着无论你是否定义了过滤器,使用Include方法加载的关联实体都会被加载,而不受过滤器的影响。......
  • ubuntu下mysql有表却提示table doesn't exist
    linux里面的mysql是区分大小写的,windows下的mysql不区分。在mysql的安装目录里面找到mysqld.cnf文件,在[mysqld]的下面(可以看到还有别的配置信息)添加  lower_case_table_names=1  就行了。我的这个配置文件的目录是/etc/mysql/mysql.conf.d文件夹下。......
  • How Does RPC & ORM Calls Works in Odoo 16
    HowRPCWorksinOdooFramework:*Odooisanopen-sourceERP(EnterpriseResourcePlanning)frameworkthatprovidesavastrangeofbusinessapplicationfunctionalities.Itfollowsaclient-serverarchitecture,wheretheclientinteractswiththeservert......
  • 详解git pull命令和使用过程中遇到的常见问题:fatal: ‘origin‘ does not appear to b
    使用gitpull同步远程代码使用git管理测试相关代码时,因为测试代码本身量级不大,所以很少使用分支,默认都使用master(主分支),当我们想要从远程origin(origin是远程仓remoterepository,clone到本地的默认名字)。当主机的master分支拉取代码过来和本地的当前分支进行合并时,需要使用如下命令:g......
  • @TableField(exist = false)是什么作用
    @TableField(exist=false)是MyBatisPlus中的注解之一,用于指示该字段在数据库表中不存在,即告诉MyBatisPlus不进行与数据库的映射。默认情况下,MyBatisPlus会将实体类中的所有字段都映射到数据库表中的相应列。但是,有时候我们可能需要在实体类中定义一些非数据库字段或临时......
  • DBeaver中使用MySQL在建表时使用DROP TABLE IF EXISTS `tbl_book`;报错
    点击查看代码DROPTABLEIFEXISTS`tbl_book`;CREATETABLE`tbl_book`(`id`int(11)NOTNULLAUTO_INCREMENT,`type`varchar(20)DEFAULTNULL,`name`varchar(50)DEFAULTNULL,`description`varchar(255)DEFAULTNULL,PRIMARYKEY(`id`))ENGINE=Inn......
  • 已解决TypeError: type numpy.ndarray doesn‘t define __round__ method
    已解决TypeError:typenumpy.ndarraydoesn’tdefineroundmethod文章目录报错问题解决方法声明报错问题之前在工作中遇到过这个坑,记录一下问题以及解决方法,不一定针对所有情况都能用,但是可以供大家参考。问题描述如下:TypeError:typenumpy.ndarraydoesn’tdefineroundm......
  • 已解决The following specifications were found to be incompatible with the existi
    已解决Thefollowingspecificationswerefoundtobeincompatiblewiththeexistingpythoninstallation文章目录报错问题解决方法PS报错问题之前在工作中遇到过这个坑,记录一下问题以及解决方法,不一定针对所有情况都能用,但是可以供大家参考。问题描述如下:UnsatisfiableErr......
  • Physical file does not exist, SAS.ReportFontsforClients.9.4.saswcur.ttf
    ERROR:Physicalfiledoesnotexist,\SAS\ReportFontsforClients\9.4\saswcur.ttfAcircumventionforthisissueistoaddthefollowingOPTIONSstatementtoyourSAScodebeforetheODSPDFFILE=statement:optionssysprintfont="Courier";To......