Closed tp closed 8 years ago
Under more complex circumstances I can get this to fail when using return true;
even without the transform-async-to-generator
plugin. Will try to extract another test case, but maybe you already have a hunch.
Also changing the return type from Promise<boolean>
to just boolean
(which works fine form Flow's perspective IIRC) does not help.
@tp please place the typecheck
plugin before the others in the list in your .babelrc
, and then try again. Babel 6 is extremely sensitive to plugin ordering.
However I think that this is happening because of a mismatch in flow and typecheck's semantics around async functions - see this issue: https://github.com/facebook/flow/issues/1259
I bet this will work:
async function test(): boolean {
return true;
}
I actually fixed this problem locally but haven't published it yet. I'll try and find time for that tonight.
Strangely now it works for me either way with Promise
What kind of change do you have pending locally?
I also think that just annotating the return function without the promise wrap is clear enough since the whole function is async, but if flow requires the Promise
Pending change accepts Promise<foo>
and foo
as identical in async functions. That's how I feel too but Flow goes the other way and compatibility with Flow is becoming more important to me now that it is supporting more and more syntax. The plan is to reach Flow compatibility in v4.
Ah, I just remembered how to get it broken:
annotating as returning Promise
Any way you could share that pending change as a development branch? Would really love to not add any more return Promise.resolve(X)
if those can be avoided.
@tp yes, sorry I meant to do it a day or two ago but a bit busy right now. I'm not near that machine at the moment but I'll push the branch or just do a patch release later today (I've added a reminder for this).
When using "transform-async-to-generator" and "transform-regenerator" together with typecheck I get an exception at runtime (see below).
When removing "transform-async-to-generator" everything runs fine so far. Maybe that plugin was not needed, then I would just leave this ticket as a future reference.
Do you think I had a config error before, or should this have worked?
.babelrc:
testcase.js:
testcase2.js:
Output: