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

BUG: join return type is Promise<DailyParticipantsObject | void> #164

Open
kwshi opened this issue May 20, 2021 · 0 comments
Open

BUG: join return type is Promise<DailyParticipantsObject | void> #164

kwshi opened this issue May 20, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@kwshi
Copy link

kwshi commented May 20, 2021

Expected behavior

The Daily.co API docs state that callObj.join resolves with a participants (type DailyParticipantsObject). This appears to be consistent with the daily.js source code. That means that the return type of join should be

Promise<DailyParticipantsObject>

Describe the bug (unexpected behavior)

The actual type specified in index.d.ts is Promise<DailyParticipantsObject | void>, which doesn't make sense:

  • First, the module.js source doesn't ever call resolve on any object other than participants, so DailyParticipantsObject should be the only response type; void is extraneous. So I believe this type is actually inconsistent with the actual behavior of the code.
  • The documentation clearly states that join should return a participants object that is meant to be used for initializing some UI upon meeting join. void indicates the absence of a return value, i.e. nothing is supposed to be done with the return value. To return Promise<DailyParticipantsObject | void> means "when this function succeeds, it will either respond with a DailyParticipantsObject... or not, who knows?". That's not really consistent with either the behavior or the stated API design.
    • Aside: the failure case (promise rejection) should not be part of the Promise type parameter. If the join function fails, it does not _resolve with a void value, it _rejects_, i.e. throws an exception that needs to be caught. The Promise` type should only indicate the type returned by the success branch.
@kwshi kwshi added the bug Something isn't working label May 20, 2021
@kwshi kwshi changed the title BUG: DailyCallObject.join returns Promise<DailyParticipantsObject | void> BUG: join returns Promise<DailyParticipantsObject | void> May 20, 2021
@kwshi kwshi changed the title BUG: join returns Promise<DailyParticipantsObject | void> BUG: join return type is Promise<DailyParticipantsObject | void> May 20, 2021
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