Async / Await ?
See original GitHub issueThis is a:
- Bug Report
Which concerns:
- flow-runtime
What is the current behaviour?
I have this function which accepts callback with specified argument type. The callback is usually async function.
function RequestQueue({ requestDone: (ctx: RequestContext) => any }) {
}
// somewhere else...
const requestDone = async (ctx: RequestContext) => {
await doSomeAsyncStuff()
}
RequestQueue({ requestDone })
RuntimeTypeError: requestDone argument “ctx” must be: RequestContext Expected: (ctx: RequestContext) => any Actual: (ctx: RequestContext) => any
What is the expected behaviour?
I can imagine this is probably bleeding edge stuff, but wanted to record this in here for some future reference. It’s possible it this be actually solved with native support for async/await. With transpilation in place it’s probably impossible task.
Which package versions are you using?
NodeJS v6.10.1
"babel-plugin-flow-runtime": "^0.10.0", "babel-plugin-syntax-flow": "^6.18.0", "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-flow-strip-types": "^6.22.0", "babel-preset-latest-minimal": "^1.1.2", "babel-preset-stage-1": "^6.22.0",
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
async function - JavaScript - MDN Web Docs - Mozilla
The async and await keywords enable asynchronous, promise-based behavior to be written in a cleaner style, avoiding the need to explicitly ...
Read more >Async/await - The Modern JavaScript Tutorial
The async keyword before a function has two effects: ... The await keyword before a promise makes JavaScript wait until that promise settles,...
Read more >JavaScript Async - W3Schools
The await keyword can only be used inside an async function. The await keyword makes the function pause the execution and wait for...
Read more >Async/await - Wikipedia
In computer programming, the async/await pattern is a syntactic feature of many programming languages that allows an asynchronous, non-blocking function to ...
Read more >Async/Await Function in JavaScript - GeeksforGeeks
Await : Await function is used to wait for the promise. It could be used within the async block only. It makes the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@FredyC thanks for digging into this, I can now replicate using:
@phpnode Well this code as a whole indeed works, however once I split it into separate files (as in my original code) it explodes… Here is the gist of how I’ve split it: https://gist.github.com/FredyC/05e980406416cf64f481dc4f8cd677a3
It did not matter when I’ve separated types only to a file, it worked well there. But with 3-way separation it almost looks like that imported
RequestContext
is different in both files.