Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identifier passed to .then() results in error #5

Closed
sgilroy opened this issue Sep 23, 2018 · 0 comments
Closed

Identifier passed to .then() results in error #5

sgilroy opened this issue Sep 23, 2018 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@sgilroy
Copy link
Owner

sgilroy commented Sep 23, 2018

The following examples each currently result in errors:

function doesSomethingWithAPromise() {
  promise.then(doSomething);
}

function returnsSomethingDone() {
  return promise.then(doSomething);
}

Error:

TypeError: Cannot read property 'type' of undefined
      at transformFunction (async-await.js:123:23)
      at NodePath.paths.forEach.path (async-await.js:166:13)
      at __paths.forEach (node_modules/jscodeshift/dist/Collection.js:76:36)
          at Array.forEach (<anonymous>)
      at Collection.forEach (node_modules/jscodeshift/dist/Collection.js:75:18)
      at replaceType (async-await.js:165:13)
      at transformer (async-await.js:173:3)
      at runInlineTest (node_modules/jscodeshift/dist/testUtils.js:28:18)
      at runTest (node_modules/jscodeshift/dist/testUtils.js:73:3)
      at Object.it (node_modules/jscodeshift/dist/testUtils.js:90:7)

Instead, they should be transformed as follows:

async function doesSomethingWithAPromise() {
  const promiseResult = await promise;
  doSomething(promiseResult);
}

async function returnsSomethingDone() {
  const promiseResult = await promise;
  return doSomething(promiseResult);
}
@sgilroy sgilroy added the bug Something isn't working label Sep 23, 2018
@sgilroy sgilroy self-assigned this Sep 23, 2018
sgilroy added a commit that referenced this issue Sep 30, 2018
@sgilroy sgilroy closed this as completed Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant