当具有 return 类型时,是否可以强制打字稿编译器检查所​​有可能的分支?

Is it possible to force the typescript compiler check all possible branches when having a return type?

我看到打字稿检查器在具有这样的功能时不会发出警告或错误:

function test(a: boolean): boolean {
    if (a) {
        return true;
    } else {
        // else branch not covered
    }
}

是否可以在 tsconfig.json 文件中设置 属性 以强制编译器进行检查? (我找不到)

noImplicitReturns 标志应该做到这一点:

https://www.typescriptlang.org/tsconfig#noImplicitReturns