Following snippet returns Unreachable code detected.ts(7027) on console.log(). Running on Visual Studio Code v1.43.2.
const foo = (() => {
try {
// operation like "return fs.readFileSync("./credentials.json")" is more likely to fail (nodejs)
// following line is just placeholder
return { val: 4 };
} catch (err) {
return { val: -1 };
}
})();
console.log(foo.val); //vs throws unreachable
Is it really a false positive?