Closed
Description
TypeScript Version: 2.0.3
Code:
const sleep = async (ms) => {
return new Promise((resolve, reject) => {
setTimeout(resolve, ms);
});
};
console.log('Kicking off async task...');
(async () => {
console.log('Sleeping for 10ms...');
await sleep(10);
console.log('Going to fail now. What happens?');
throw new Error();
})();
console.log('Kicked off.');
Expected behavior: compilation succeeds, and runs with the following output:
Kicking off async task...
Sleeping for 10ms...
Kicked off.
Going to fail now. What happens?
Actual behavior: compilation fails:
async.ts(16,1): error TS7027: Unreachable code detected.