TypeScript報(bào)錯(cuò)
一、Property propDD has no initializer and is not definitely assigned in the constructor
1、object類(lèi)型

解決方案
檢測(cè)報(bào)錯(cuò)代碼 @Prop() propDD: object; 修改后 方式一 @Prop({ type: Object, default: {} }) propDD: any; 方式二 @Prop() propDD?: object;
2、array類(lèi)型

解決方案 檢測(cè)報(bào)錯(cuò)代碼 @Prop() propF: string[]; @Prop() propG: Array<number>; 修改后 @Prop() propF?: string[];
原文鏈接:https://blog.csdn.net/Tomoe20/article/details/106210357/
二、any類(lèi)型警告
(property) DateHelper.prmimaryKey: string
元素隱式具有 "any" 類(lèi)型,因?yàn)轭?lèi)型為 "string" 的表達(dá)式不能用于索引類(lèi)型 "{}"。
在類(lèi)型 "{}" 上找不到具有類(lèi)型為 "string" 的參數(shù)的索引簽名。ts(7053)
速覽問(wèn)題 (Alt+F8) 沒(méi)有可用的快速修復(fù)
我們?cè)陧?xiàng)目中的tsconfig.json文件中添加:
"suppressImplicitAnyIndexErrors":true,
原文鏈接:https://blog.csdn.net/beLaity/article/details/108527556
如果覺(jué)得本文對(duì)您有幫助~可以微信支持一下:




浙公網(wǎng)安備 33010602011771號(hào)