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

BREAKING CHANGE: v0.16 Room.has(contact) change from Sycn to Async #1289

Closed
huan opened this issue Jun 8, 2018 · 2 comments
Closed

BREAKING CHANGE: v0.16 Room.has(contact) change from Sycn to Async #1289

huan opened this issue Jun 8, 2018 · 2 comments

Comments

@huan
Copy link
Member

huan commented Jun 8, 2018

WARNING: This change will let us make more mistakes:

if (room.has(contact)) {
  console.error('here will always be executed because Promise === true')
}

So we have to enable tslint to check the floating promise for us. So should all the developers do if you are using Wechaty:

Related configuration in tslint.json:

{
    "extends": "tslint:recommended",
    "rules": {
        "no-floating-promises": true
    }
}

See Also

Before

const exist = room.has(contact)

After

const exist = await room.has(contact)
@huan
Copy link
Member Author

huan commented Jun 15, 2018

Have to think more about how to deal with the floating promise when a user forgets to await.

@huan
Copy link
Member Author

huan commented Jun 19, 2018

use tslint to check floating promise will solve this issue.

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

No branches or pull requests

2 participants