TypeScript版本: master
搜索词:
代码:
declare const o: { c?: 1; };
switch (0) {
case 0:
break;
case o.c && o.c.valueOf():
case o.c && o.c.valueOf():
break;
}
预期行为:
通过
实际行为:
$ node built/local/tsc.js index.ts --strictNullChecks
index.ts:5:15 - error TS2532: Object is possibly 'undefined'.
5 case o.c && o.c.valueOf():
~~~
Playground链接:
相关问题:
1条答案
按热度按时间pdsfdshx1#
同时使用
declare const c?: number;
并移除o.
的所有位置。