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

fix: make local optional in typescript definitions #196

Open
wants to merge 1 commit into
base: daily-js-releases
Choose a base branch
from

Conversation

jamsea
Copy link

@jamsea jamsea commented Oct 18, 2022

@lazeratops and I noticed that local is sometimes undefined. Currently our workaround is to add a //@ts-ignore in the project we're working on. This should fix this issue.

@jamsea jamsea requested a review from lazeratops October 18, 2022 07:48
@lazeratops
Copy link
Contributor

lazeratops commented Oct 18, 2022

The change itself LGTM, but I think we should get some added feedback from product eng as well. I am wondering if we need to take any special considerations of backwards compatibility here, since I suppose this would could break transpiration for upgrading typescript customers who may not already check for truthiness.

(Also I think we may want to use the main branch as the merge target here, unless the workflow has changed)

@@ -125,7 +125,7 @@ export type DailyNonFatalErrorType =
export type DailyNetworkTopology = 'sfu' | 'peer';

export interface DailyParticipantsObject {
local: DailyParticipant;
local?: DailyParticipant;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll let @kompfner weigh in here, but I think maybe the more accurate thing to do would be to change the return of participants()(line 1105) to return DailyParticipantsObject || {}. The only time local can be undefined is before preAuth/startCamera/join or after leave (basically.. not in a call) and in this case, participants() will return {}. The other uses of DailyParticipantsObject come at times when you are in a call and should be guaranteed to have a local participant. With the change I'm proposing, we can keep this guarantee.

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.

3 participants