TypeScript报错

一、Property propDD has no initializer and is not definitely assigned in the constructor

1、object类型

 

 

 

解决方案  

检测报错代码
@Prop() propDD: object;
修改后
方式一
@Prop({ type: Object, default: {} }) propDD: any;
方式二
@Prop() propDD?: object;


2、array类型

 

 

 

解决方案

检测报错代码
@Prop() propF: string[];
@Prop() propG: Array<number>;
修改后
@Prop() propF?: string[];

 

原文链接:https://blog.csdn.net/Tomoe20/article/details/106210357/

二、any类型警告

(property) DateHelper.prmimaryKey: string
元素隐式具有 "any" 类型,因为类型为 "string" 的表达式不能用于索引类型 "{}"。
在类型 "{}" 上找不到具有类型为 "string" 的参数的索引签名。ts(7053)
速览问题 (Alt+F8) 没有可用的快速修复

我们在项目中的tsconfig.json文件中添加:

 "suppressImplicitAnyIndexErrors":true,

 

 


原文链接:https://blog.csdn.net/beLaity/article/details/108527556

 

posted @ 2021-03-03 07:15  starof  阅读(686)  评论(0编辑  收藏  举报