Closed grofit closed 7 years ago
Luckily you can work around this by targeting es2017 in the meantime - Node 7.6 has supported async await for a bit now.
@weswigham can you take a look
I can't seem to repro this with the following:
// @target: es2015
// @module: commonjs
declare const doSomethingThatRetunsPromise: any;
class Foo {
private someExpressRoute = async (req: Request, res: {
status(x: number): { send: Function };
}) => {
try
{
await doSomethingThatRetunsPromise(); // await but no return
res.status(200).send();
}
catch(error)
{
res.status(500).send({ error: "Something went wrong" });
}
}
}
@grofit Does this still repro for you with typesript@next
? If so, can I have some more context to figure out what's going on?
--t es5
does it for me.
my bad. i can not reproduce this locally on latest either.
I was changing build config a lot so not entirely sure if it was es5 that was causing it, it seems fine at the moment and I am not sure if it was the await which caused it, but I have a version in the private npm repo with this problem, so TSC has output this at some point as I dont touch the dist folder (where it outputs to) but I cannot say for sure what caused it.
Thanks for looking though.
TypeScript Version: 2.5.2
I am facing an issue in node 8 where my async method is bombing with the error:
After taking a look through it seems to be that all the working methods have the
__awaiter
added as the method body wrapper, however this one does not. The only thing that appears to be different between this and other methods that get the__awaiter
is that this contains anawait
without a response.I am using Node 8 as platform I am running on, and I am compiling the ts with:
Here is an example bit of code that shows what happens:
Example code
Expected behavior:
Actual behavior:
I am not sure if the expected behaviour is correct as not entirely sure what generator syntax is valid, but as TS compiles without any errors I would assume the code should be fine, but the other methods with awaiter bit do not cause any problems.