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

Avoid converting a getter/setter into an invalid async method #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yonran
Copy link

@yonran yonran commented Aug 18, 2021

Previously, async-await.js would convert a getter/setter into an invalid async getter/setter.

Input:

class A {
  method() {return a().then(b => 'convert')}
  get prop() {return a().then(b => 'getter')}
  set prop(val) {return a(val).then(b => 'setter')}
}

Output before this PR: async get and async set methods are created, but this is invalid ECMAScript and invalid TypeScript:

class A {
  async method() {
    const b = await a();
    return 'convert';
  }
  async get prop() {
    const b = await a();
    return 'getter';
  }
  async set prop(val) {
    const b = await a(val);
    return 'setter';
  }
}

Output after this PR: get and set methods are not converted to async.

class A {
  async method() {
    const b = await a();
    return 'convert';
  }
  get prop() {return a().then(b => 'getter')}
  set prop(val) {return a(val).then(b => 'setter')}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant