[英]error TS2532: Object is possibly 'undefined' - Using "?." operator
If you read the documentation |如果您阅读文档 | 3.7 you will see that. 3.7你会看到的。
That might result in dividing undefined, which is why in strictNullChecks, the following is an error.这可能会导致除 undefined,这就是为什么在 strictNullChecks 中,以下是错误的。
function barPercentage(foo?: { bar: number }) {
return foo?.bar / 100;
// ~~~~~~~~
// Error: Object is possibly undefined.
}
I believe that this is the case.我相信情况确实如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.