TypeScript可选链分支覆盖率疑问:总分支数为何是4而非2?
TypeScript可选链分支覆盖率疑问
我在理解TypeScript可选链的分支覆盖率时遇到了问题。
我的代码如下:
type testingType = { b?: { a?: number }; }; export function example(input: testingType) { return input.b?.a; }
测试用例(仅为生成覆盖率报告强制通过):
test('test', () => { example({}); expect(1).toBe(1); });
覆盖率报告显示分支覆盖率为3/4,我无法理解总分支数为何是4。按我的理解应该只有2个分支:
b已定义b未定义
内容的提问来源于stack exchange,提问作者tpszhao
相关产品推荐
相关产品推荐

