老师,我对Record<number, Goods>类型的变量添加了一个字符串属性,为什么没报错呢
来源:10-17 【高级类型 Record 真实应用】 异步数据扁平化 的实现【 实现方式2】

慕侠8534226
2021-11-03
老师,像图中那样,我给变量array添加了一个字符串属性,为什么没报错呢?不应该只能添加数字类型的属性吗?
写回答
2回答
-
进入 tsconfig.json 开启 "strict": true 或 "noImplicitAny": true
如果已经指定了 include ,需要覆盖该ts文件,如下:[compilerOptions 和include是并列关系】
"compilerOptions": {
...............
},
"include": [ // 需要编译的ts文件路径 **表示多级目录都包括
"./src/**/*.ts", // 匹配src下所有的ts文件
]
,
012021-11-04 -
keviny79
2021-11-03
编译错误
00
相似问题