This repository was archived by the owner on Jun 10, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 25
Variables goes out of scope prematurely #123
Copy link
Copy link
Open
Description
I had this code:
1 const cid = await getCid(slackUsername)
2 await replyFn(`Creating time report for ${year} ${month} and ${cid}`)
3 const resp = await request.post(config.apiUrl + `/create-time-report/${cid}/${year}/${month}`)And I got this strange error that cid was undefined on line 3, but it was defined properly on line 2.
After a lot of crying i looked into the generated code and i found that it had been transpiled to:
1 return Promise.resolve().then(function () {
2 return getCid(slackUsername);
3 }).then(function (_resp) {
4 const cid = _resp;
5 return replyFn(`Creating time report for ${year} ${month} and ${cid}`);
6 }).then(function () {
7 return request.post(config.apiUrl + `/create-time-report/${cid}/${year}/${month}`)
8 })As is clear from the transpiled code cid goes out of scope prematurely.
I am running version 1.0.5 of async-to-promises.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels